GitHub

Kate Langwig, Virginia Tech

Welcome to the EEID 2026 workshop

  • Click here and scroll down to follow along with course materials

Pre-Break Goals

  • Introduce Git & GitHub
  • learn to link GitHub to RStudio
  • edit your first script and send it to GitHub

The Replication Crisis

Very few scientific studies are ever actually replicated, and when we try to replicate the results of studies we often can’t.

Why don’t we replicate more studies?

What does it mean for research to be “Reproducible”?

Research is reproducible when others can reproduce the results of a scientific study given only the original data, code, and documentation

Who benefits from reproducible research?

  • Researchers
    • Remember how and why you did what you did
    • Quickly simplify and modify analyses
    • Makes you trustworthy
    • Increases citation rates
  • Research community
    • Lets people learn from your work
    • Lets people find your mistakes
    • Lets people actually reproduce your results

Working in Github

  • Git is version control system, with the original purpose of allowing groups to work collaboratively on software projects
  • Git manages the evolution of a set of files - called a repository
  • A repository is essentially a folder where you store your stuff
  • Version control works a bit like “Track Changes” in word, Git will track the changes we make to our code so we can return to previous versions
  • It also allows collaboration so I can look at your code and make changes - a bit like a more complicated version of Google Docs

Terminology

  • repository: like a project folder
  • All data, code, and outputs relevant to a particular project live together in the same repository (“repo”)
  • It is usually a local folder on your computer. You can keep code files, text files, image files, you name it, inside a repository.
  • Track revision history within each repo
  • Make different repositories for different projects

Terminology

  • commit: This is the command that gives Git its power. When you commit, you are taking a “snapshot” of your repository at that point in time, giving you a checkpoint to which you can reevaluate or restore your project to any previous state.When you first start “commiting”, it is important to remember this is taking the picture, not SENDING the picture. (Sending is called “pushing”)
  • we use commits to track the sequential changes we are making on our local version and then PUSH them back to remote repo

Terminology cont.

  • push: This is how you upload your file to GitHub. Remember, you need to both commit and push for your file to be sent to GitHub.

  • pull: This is how you bring edits from GitHub to your computer. If I make changes to your code, pulling will integrate them. You will need to do this every time you open your project.

  • branch: How do multiple people work on a project at the same time without Git getting them confused? Usually, they “branch off” of the main project with their own versions full of changes they themselves have made. After they’re done, it’s time to “merge” that branch back with the “master,” the main directory of the project. Don’t worry too much about this now.

GitHub workflow

  • Pull latest updates from cloud to computer
  • Edit scripts, graphs, other files
  • Review changes and commit them
  • Push commits to the (cloud) repository

Class pledge

I solemnly swear that every time I open my repository I will (1) Pull, (2) make changes I want to make, (3) Commit, (4) Push.

I swear I will never make a change to my repository without committing and pushing.

Sending your files to our workshop repository

  • We have an “organization” account for our workshop
  • Can make repos public or private
  • Why should we want things open-source? Why not?

FAIR Data Practices

Data obtained with support from public funds (such as NSF or NIH) are usually required to be made available to other scientists and the public.

In particular we want our data to be FAIR:

  • Findable
  • Accessible
  • Interoperable
  • Reproducible

Pre-course homework

Register for a GitHub username

Installing Git

  • Hopefully you have installed Git!
  • If not, please do so here, following the instructions: http://happygitwithr.com/install-git.html#install-git
  • Try to install git in the most scientific way possible - if one way doesn’t work, try the next, and google your mistakes!

Install a Git client

Enter your user name into this form

  • enter your github user name here
  • clickable link for Kate: https://docs.google.com/forms/d/1hfFzC5CFDJAO-OVXBCEcVQk9IJ465nnEf9DA1PbVZWI/edit

Tasks for today

  • Configure Git on your computer
  • Create a personal access token
  • Set up a repository on GitHub
  • Clone that repository to your computer
  • Edit something in your repository
  • Commit your edits using Git
  • Push your edits to GitHub

1. Configure Git on your computer

  • Open RStudio & click File–>New File –> RScript
  • Type the following:
## install if needed (only do this once)
## install.packages("usethis")
library(usethis)
use_git_config(user.name = "Jane Doe", "user.email = jane@vt.edu")
  • Make sure you use the user name and email you used to sign up for github!

2. Create a personal access token

  • when we interact with Git, we need to tell it that we are a specific user that is allowed to make changes to the folder
  • We have to create a token that we store on our computers to allow us access to connect to GitHub
  • open this link
  • copy and paste code and follow directions
#abbreviated here:
usethis::create_github_token()
#Look over the scopes; I highly recommend selecting 
#“repo”, “user”, and “workflow”. 
#Click “Generate token”.
install.packages("gitcreds")
library(gitcreds)
gitcreds_set()
#paste your personal access token
gitcreds_get()

3. Set up a repository on GitHub

  • navigate to https://github.com/EEIDWorkshop2026
  • click the green New button to create a repository
    • you can also do this on your own account, but if you make them here, I can help
    • If I haven’t sent your Github user name, you won’t be able to access this
  • type the name of your repository (I recommend lastname_project)
  • choose ‘Public’ for now
  • check the box to add a a README file
  • click ‘Create Repository’

4. Clone that repository to your computer

  • In RStudio, click File–>New Project–>Version Control–>Git
  • In Repository Name: Copy and paste the hyperlink from the browser of your repository
    • It will have a name like this: https://github.com/EEIDWorkshop2026/yourname
  • In Project Directory: It should have the same name as the repo on GitHub (should autofill). It should be the name after the last /
  • Create Project as subdirectory: Pick a smart place on your computer that you find without using a search function
  • Click OK and you should clone into a new window that says ‘YourRepo - main’

4 cont. Exploring your Repository

  • this repository is the same as your GitHub repo that ‘lives’ on your local computer
  • on the bottom right - Files tab, you should see your README and a file labeled REPO.Rproj
  • this is a shortcut to your working directory and is how you can easily access and shortcut scripts using relative paths
  • unlike Dropbox or google drive, GitHub doesn’t automatically detect changes to your local folder. You need to tell it you are making a change using commit, and then send those changes using push.

5. Edit something in your repository

  • Close the RStudio window and find the place where you stored the your GitHub repo
  • add something to that folder (a script, an excel file) by copying and pasting
  • double click the file that ends in the extension .Rproj to open your Git linked project
  • Using the files tab, open the README file and type something there. This is the file that tells other users what is inside your project and what it does, but for now, you can add any text you want. Save the file when you are done (don’t change the name)

6. Commit & Push your edits using Git

  • at the top of your RStudio screen there is a sideways GIT button (it is gray, red, and green) next to AddIns
  • click the dropdown and select ‘Commit’
  • on the left side, you’ll see items with changes. It should be your README and the files you added.
  • check the boxes to stage the files and the Status should change to an M
  • in the box on the right, type a commit message (this is mandatory)
  • your message likely includes a very short description of what you did ‘added file, README’
  • press commit
  • make sure you don’t get any errors
  • press the ‘Push’ button

7. Confirm that Push worked

8. Adding collaborators

  • henceforth, you will always add & edit files in this manner. You should not directly modify files using the browser
  • If you want to collaborate with others, while on your GitHub repo, you will go to settings–>collaborator and teams–Add People
  • you can then search by their user name (try adding me klangwig)
  • can you can control what rights you give them

Collaborating using GitHub

  • if you have a collaborator on your project, they might make changes to something
  • to avoid lots of merge conflicts, you should always ‘pull’ when you open your project
  • this will make sure you are working on the most recent version
  • if you and your collaborator are both working on the project and haven’t branched (or are merging branches), you’ll need to resolve merge issues
  • this has to be done using the command line or the Desktop client (hence my recommendation for downloading)

Going further

  • Lots more to learn but you’ve accomplished the basics!
  • Take a look at all the commands here: https://happygitwithr.com/git-commands.html
  • Play around with GitHub desktop to get a feel for what it does
  • Venture into the shell and command line as you begin to explore more powerful GitHub tools