If you’ve ever worked on a file called something like:
report_v2_final_FINAL_reallyfinal.docx
…then Git is here to save your sanity.
Git is a tool that helps you:
Keep backups – If your computer is lost or damaged, you can get your files back from GitHub.
Track changes – See what you changed, when, and why. No more saving 10 versions of the same file.
Collaborate – Work with others without overwriting each other’s work.
Recommended video
Alice Bartlett explains Git for beginners:
Slides from her talk
We’ll go step-by-step. You only need to do this once per computer.
R has some great tools that help make using Git easier.
Download R: https://cran.rstudio.com/
Run the R installer – Keep all default settings.
Download RStudio: https://posit.co/download/rstudio-desktop/
Run the RStudio installer – Keep all default settings.
Download Git for Windows: gitforwindows.org
Run the installer – Keep all default settings.
Check it worked:
git --versionRun these commands in RStudio (replace with your name and the email you used for GitHub):
#install.package("usethis") #only run once to install package
library(usethis)
usethis::use_git_config(user.name = "Your Name Here",
user.email= "Your Email Here")
We use a special “access token” (a long password) so RStudio can talk to GitHub.
Check if you already have one:
#install.packages(gitcreds) #run the first time
library(gitcreds)
gitcreds::gitcreds_get()
## <gitcreds>
## protocol: https
## host : github.com
## username: katiewampler
## password: <-- hidden -->
If your GitHub username shows up, you can skip ahead. If not:
Create a new token:
#install.packages(gitcreds) #run the first time
library(gitcreds)
usethis::create_github_token()
This will open GitHub in your browser — scroll down, click Generate token (green button), and copy it.
Store your token:
This is important as once your token is generated you can’t get it from GitHub again.
gitcreds::gitcreds_set()
When prompted for a password, paste your token. Done!
GitHub Desktop gives you a friendlier interface for managing files.
Download: desktop.github.com
Install and open the program.
Go to File → Options → Accounts and sign in to GitHub.
Now you can:
Save versions of your work without making endless copies
Restore old versions
Share work with others safely
Keep a backup online in case disaster strikes
Happy Git and GitHub for the useR – excellent beginner guide
Git for Humans – Alice Bartlett – friendly talk