Meet the toolkit: Git and GitHub



Data visualization and transformation

Data Science with R

Learning goals

Configuring Git

install.packages("usethis")

usethis::use_git_config(
  user.name = "Your name", 
  user.email = "Email associated with your GitHub account"
 )

By the end of the course, you will …

  • understand the importance of version control

  • understand how we use Git & GitHub for version control

  • set up and configure a personal access token

  • understand how to clone your course project

Version control

Versioning - done badly

Versioning - done better

Versioning - done even better

with human readable messages

Git and GitHub

Git logo

  • It’s not the only version control system, but it’s a very popular one

  • Git is a version control system – like “Track Changes” features from Microsoft Word, on steroids

GitHub logo

  • GitHub is the home for your Git-based projects on the internet – like DropBox but much, much better

  • We will use GitHub as a platform for your course projects

Let’s take a tour of

Project Repo

Tour recap

Create a GitHub account

  • Go to Github and walk through the steps for creating an account.

  • You’ll need to choose a user name. I recommend reviewing the user name advice here before choosing a username.

Creating a new repository

  • Make sure you are the owner

  • We recommend naming your repo the same name as the original

Personal access token

  • Get a personal access token (PAT): usethis::create_github_token()

  • Copy your PAT

  • Insert PAT to configure Git, GitHub and R gitcreds::gitcreds_set()

> gitcreds::gitcreds_set()

? Enter password or token: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-> Adding new credentials...
-> Removing credentials from cache...
-> Done.

Clone repository

Clone repository

Clone repository

Project

  • File -> New Project

  • Version control -> Git

  • Paste -> Create project

Version control workflow

Environments window

Environments window

Git and GitHub tips

  • There are many many git commands … but very few people know them all. 99% of the time you will use git to push, commit, and pull

  • If you are looking for additional resources for working with git and R, continue reading: happygitwithr.com.