Step-by-step setup

September 17 · Evening session

Set up your first repository, make your first commits, and practice pulling and pushing changes.

1. Today’s class: GitHub and your first repository

Create your GitHub account, install the required software, create your first repository, add your partner as a collaborator, and practice the Git workflow. Write your GitHub username on a sticky note and give it to Jory or Niál by the end of class. They will invite you to the course organization.

2. Practice R in your repository

Create an R script in your repository and work through Intro2R: Basics of R. Commit and push your script as you work.

3. After you join the organization

You are welcome to explore the coding introduction script, but this is optional. We will use our first course template next week for Module 1.

Start where you are. You may skip Steps 1 and 2 if you have already completed them. Complete Steps 3–7 in order. Step 8 is optional.

01

Create a GitHub account

Already have an account? Sign in at github.com, confirm that you know your username, and skip to Step 2.

  1. Go to GitHub Sign Up.
  2. Use an email address you check regularly and choose a professional username. Your username will be visible in repository links and contribution history.
  3. Verify your email address and sign in.
  4. Optional: apply for the GitHub Student Developer Pack with your ETH email. Approval is not required to continue this exercise.
02

Install R, RStudio, Git, and GitHub CLI

Already installed all four? Open RStudio once to confirm it starts, then skip to Step 3.

Install these in this order. R is the language, RStudio is the IDE where you will work (if you prefer to use another IDE, that is fine), Git records and shares changes, and GitHub CLI provides an easier browser sign-in.

  1. Install R for your operating system.
  2. Install the free version of RStudio Desktop.
  3. Install Git. On macOS, opening Terminal and running git --version may prompt you to install the required command-line tools.
  4. Install GitHub CLI.
  5. Restart RStudio after Git and GitHub CLI are installed, then complete the authentication steps below.

Authenticate with GitHub CLI

In RStudio, open Tools > Terminal > New Terminal and run these commands one at a time:

gh auth login --web --git-protocol https
    gh auth setup-git
    gh auth status
  1. The first command displays a one-time code and opens GitHub in your browser. Sign in to the correct account, enter the code if asked, and approve access.
  2. Return to the RStudio Terminal. Run the second command to connect Git to your GitHub CLI login.
  3. Run the third command. Continue when it says you are logged in to github.com.

You normally do this only once on each computer. The saved login works with every repository that your GitHub account is allowed to access.

Confirm that RStudio can find Git

In RStudio, open Tools > Global Options > Git/SVN. Confirm that Enable version control interface for RStudio projects is selected and that a Git executable is listed. If it is blank, browse to your Git executable and restart RStudio.

Set the name and email attached to your commits

In RStudio, open Tools > Terminal > New Terminal, then run the following commands with your own details. Use an email connected to your GitHub account.

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
03

Give your GitHub username to the TAs

Jory and Niál need your username before they can invite you to the course GitHub organization.

  1. Copy your GitHub username from your profile page. Do not send your password.
  2. Write your GitHub username clearly on a sticky note.
  3. Give the sticky note to Jory or Niál by the end of class.
  4. Continue to Step 4 while you wait for the invitation.
  5. When the invitation arrives, make sure you are signed in to the correct GitHub account, then select Join or Accept invitation.
Cannot find the invitation? Check your email and GitHub organization settings. Invitations are not instant; ask Jory or Niál if it has not arrived.
04

Create your first repository

  1. On GitHub, select the + menu at the top right, then select New repository.
  2. Choose your personal GitHub account as the Owner.
  3. Name the repository coding-intro.
  4. Choose Private visibility and select Add a README file.
  5. Select Create repository.

Confirm that the repository page shows its name and a README.md file before continuing.

05

Add your partner as a collaborator

Adding your partner lets both of you practice sharing changes through GitHub.

  1. Open your new repository on GitHub and select the Settings tab.
  2. In the left sidebar, under Access, select Collaborators or Collaborators and teams.
  3. Select Add people, search for your partner’s GitHub username, select the matching account, and confirm the invitation.
  4. If GitHub asks you to choose a role, select Write. Do not give your partner administrator access.
GitHub will show the invitation as Pending until your partner accepts it.
06

Set up the project in local RStudio

Clone your repository

  1. On your repository page in GitHub, select the green Code button.
  2. Select HTTPS, then copy the repository URL. It should end in .git.
  3. Open RStudio and select File > New Project > Version Control > Git.
  4. Paste the URL into Repository URL. RStudio should fill in the project directory name automatically.
  5. For Create project as a subdirectory of, choose a folder where you keep coursework, such as Documents/DSEP. Choose a location you can find again; avoid placing the project inside another Git repository.
  6. Select Create Project. RStudio will download, or clone, the repository and open the local project.

Check the result

  • The project name appears at the top right of RStudio.
  • The Files pane shows README.md.
  • A Git tab appears next to Environment and History.
Fallback: create a token only if GitHub CLI sign-in does not work

GitHub account passwords do not work for Git operations over HTTPS. If you must use a personal access token:

  1. Open GitHub’s fine-grained token form.
  2. Name it DSEP RStudio and choose an expiration date after the course ends.
  3. For Resource owner, choose the account or course organization where your course repositories will live.
  4. Under Repository access, choose All repositories if the course will create several repositories under that owner. If that owner also contains unrelated repositories, choose Only select repositories and add each new course repository to this same token.
  5. Under Repository permissions, give Contents read and write access. Generate the token and copy it immediately; GitHub shows it only once.
  6. In the RStudio Console, run the commands below. Paste the token only when gitcreds prompts for it.
install.packages("gitcreds")
gitcreds::gitcreds_set()

Keep the token private. Never put it in an R script, README, repository URL, assignment, email, or chat message.

If GitHub marks the token pending or asks you to authorize it for single sign-on, complete that authorization or contact the course team.

07

Create an R script, commit, pull, and push

This is the workflow you will repeat throughout the course. A commit records a named checkpoint on your computer; a pull downloads commits from GitHub; and a push sends your local commits to GitHub.

Your script should load at least one package and contain a few lines of working code. For example:

library(tidyverse)
library(palmerpenguins)

penguin_summary <- penguins |>
    drop_na(species, body_mass_g) |>
    group_by(species) |>
    summarise(mean_body_mass_g = mean(body_mass_g))

penguin_summary
  1. In RStudio, select File > New File > R Script and save it in the project as basics-r.R.
  2. If the packages are not installed, run install.packages(c("tidyverse", "palmerpenguins")) once in the RStudio Console. Do not put the installation command in your script.
  3. Add the package-loading commands and a few lines of code, such as the penguins example above, to your script. Run each line and save the file.
  4. Continue practicing with Intro2R: Basics of R if you have time.
  5. Open the Git pane. The new file should appear with a question mark because Git is not tracking it yet.
  6. Select the checkbox beside basics-r.R. This adds, or stages, the file for the next commit.
  7. Select Commit. Review the displayed change, enter a short message such as Practice R basics, then select Commit.
  8. Close the commit window, then select the green upward arrow labeled Push to upload your script to GitHub. Complete GitHub sign-in if prompted.
  9. Return to the repository page in your browser, refresh it, and confirm that basics-r.R appears.

Practice a pull with your partner

  1. Your partner accepts the collaborator invitation, clones the repository, and opens it in RStudio.
  2. Your partner adds one comment to basics-r.R, then commits and pushes the change.
  3. On your computer, select the blue downward arrow labeled Pull in RStudio’s Git pane.
  4. Open basics-r.R and confirm that your partner’s comment appears.
Optional extension for advanced groups: If you have successfully pushed and pulled changes and already feel comfortable with R basics such as variables, begin exploring global biodiversity data and cloud-native computing through GBIF’s introduction to Apache Arrow and Parquet. These ideas will be relevant to Module 1.

Terminal equivalent

The RStudio buttons run the same Git commands shown below. You do not need to run these now, but you may use them if you prefer the terminal.

git status
git add basics-r.R
git commit -m "Practice R basics"
git pull
git push

If the push does not work

  • Authentication failed: run gh auth status in the RStudio Terminal. If you are not logged in, run gh auth login --web --git-protocol https and gh auth setup-git again.
  • 403 or permission denied: confirm that you signed in to the account that joined the course organization and that the organization has authorized your access.
  • Repository not found: confirm that you accepted the organization invitation, cloned your own repository, and copied the correct HTTPS URL.
  • Push rejected because the remote contains work: select the blue downward arrow to pull, resolve any conflicts, and push again.
Ask the course team before using force push. If you used the token fallback and an incorrect token is stored, run gitcreds::gitcreds_delete(), then gitcreds::gitcreds_set() and enter the replacement token.
08

Optional: explore the organization

Not in the organization yet? You are finished for today. Return to this optional step after you accept the invitation.

  1. Open the course organization and select its Repositories tab.
  2. Find and open the coding introduction repository.
  3. Explore the intro script if you wish. You do not need to complete it now.
We will create the first repository from a course template next week for Module 1.

Finished when...