Overview
Teaching: 30 min
Exercises: 15 minQuestions
How can we use Git and GitHub in Rstudio
Objectives
- “become familiar with Rstudio’s Git and GitHub integration”
Requirement
- Install Git
- Install RStudio and be familiar with its operation
Follow along demo:
rr-version-control-demo repository.RStudio project.rr-version-control-demo GitHub repository.Fork the rr-version-control-demo repository.
Now you have a copy of rr-version-control-demo repository in your account, woohoo!
How can I tell if I am looking at my fork or the original repository?
[your-github-name]/rr-version-control-demo
forked from Reproducible-Science-Curriculum/rr-version-control-demoClone your forked repository to obtain a local copy of the files .
RStudio, go to “File > New Project”Edit a file in this repository/project.
gdp-life-expectancy.Rmd and knit.Stage your changes to be committed.
gdp-life-expectancy.Rmd and gdp-life-expectancy.html by checking the boxes next to then, and hit Commit.Don’t worry about the other files that appear in this pane, we’ll get to them in a bit.
View the diff, and commit your changes, with a commit message.
.Rmd file. You can view it for the .HTML file as well if you like.Commit.Push your changes to your own fork of the the rr-version-control-demo GitHub repository.
push: When using git push always means pushing commits from your local respository (your computer) to a remote repository (GitHub).
Getting an error? Can’t push? See here under GitHub password. Ask a helper!
File tracking:
The RStudio Git pane lists every file that’s been added, modified or deleted.
The icon describes the change:
Modified You’ve changed the contents of the file.
Untracked: You’ve added a new file that Git hasn’t seen before.
Deleted: You’ve deleted a file.
Renamed: You’ve renamed a file.You can get more details about modifications with a : 
.gitignore and .rr-version-control-demo.Rproj.rr-version-control-demo.Rproj: This file maintains metadata on the R project..gitignore: Git uses this file to determine which files and directories to ignore, before you make a commit.Key Points
RStudio allows for Git and GitHub integration