Alice Bartlett of the Financial Times gave a great talk on this in 2016. She briefly shows and discusses the terrible user interface (UI). You can ignore those parts. We’ll talk about GitHub desktop that will make it much easier to work with Git. Slides from her talk are here.
To sum up, for our purposes Git is great because:
Hopefully now I’ve convinced you that using GitHub is a good thing, because setting them up the first time can been a little bit challenging. But the good news is you should only have to do this one time per computer. We’ll walk through how to do it on a Windows computer, but if you’re using a different operating system check out this resource on how to set up Git.
Download git for windows: https://gitforwindows.org/
Run the executable (.exe) file for installing git, you can leave all the default settings the way they are.
Next we’ll double check that git was successfully installed:
Open up RStudio, in the bottom panel you’ll see by default the console, but next to that you can select the terminal. Click terminal to switch to it.
Here type git -- version
, if you’ve got git
installed it will tell you what version you have installed. If not, try
to install again or ask Katie for help.
#install.package("usethis") #only run once to install package
library(usethis)
#tell git your name and email, should be email associated with your github account
usethis::use_git_config(user.name = "Your Name Here",
user.email= "Your Email Here")
Now we’ll get GitHub set up, this is the online, remote which will store all your data online.
If you’re unsure if you’ve done this before, run the following lines of code if your username comes up, you’ve already got GitHub talking with RStudio and you can skip to step 7:
#install.packages(gitcreds) #run the first time
library(gitcreds)
gitcreds::gitcreds_get()
## <gitcreds>
## protocol: https
## host : github.com
## username: katiewampler
## password: <-- hidden -->
If you’ve never done this before run the following lines of code. This code will open up a GitHub window, you can leave the defaults as is. Just scroll to the bottom and hit the green “Generate token” button.
#install.packages(gitcreds) #run the first time
library(gitcreds)
usethis::create_github_token()
Now we’ll use the gitcreds
package to securely store
your token, because once it’s generated you can’t get it from GitHub
again. When it asks for password or token, paste the token you just got
from GitHub.
gitcreds::gitcreds_set()
The last thing we need to install is GitHub desktop. While we can interface with GitHub from RStudio, GitHub desktop is even more user friendly.
Download the installer and run to install (https://desktop.github.com/download/).
Once it’s installed, open it and go to file -> options -> accounts. Click the button to sign into GitHub online and follow the prompts.
That’s it, now you’re ready to enjoy effortless version control and data backups!
Hester, J. B., the STAT 545 TAs, Jim. (n.d.). Let’s Git started | Happy Git and GitHub for the useR. Retrieved from https://happygitwithr.com/
Git for Humans – Alice Bartlett at UX Brighton 2016. (2017). Retrieved from https://www.youtube.com/watch?v=eWxxfttcMts