100 Putting (G)it All together in RStudio
Written by Matthew Wankiewicz and last updated on 7 October 2021.
100.1 Introduction
Now that you have learned about the different GitHub operations and processes that you will need for future projects, we can now look at how to use these commands in RStudio. Using the commands in RStudio is a much better alternative because you will have all of your work located in one place. This lesson will look at how to push, pull, fork and do other GitHub operations using RStudio.
Before beginning, make sure you have Git downloaded onto your computer or else these commands will not work.
100.2 Bringing the Repo into R
Before working with a GitHub repository in RStudio, make sure you have a GitHub repository you are ready to work with.
Now that you have created the repo, you can click the green button to get a link which will help you clone the repository. To open this in R, open up R then click on the cube with a plus over it to create a new project, click version control and then Git. Now, paste in the url you copied earlier and create the project. Now you have a project in R which is connected to GitHub. Now you can create new files and upload them to GitHub so others can see.
100.6 Common Mistakes and Errors
The most common error that will occur when working with GitHub in R are conflicts. Conflicts occur when you attempt to make a change on a file and when you upload the file to GitHub it doesn’t match its records. The previous module called “Dealing with Conflicts” explains what to do when these errors occur.
100.7 Next Steps
For more information about using GitHub in RStudio, check out the following links:
- This blog post shows how to use git in RStudio and highlights the terminal commands: https://resources.github.com/whitepapers/github-and-rstudio/
100.8 Questions
- True or False, git must be downloaded on your computer for GitHub functions to work in RStudio?
- True
- False
- Which button is not included in the Git pane in RStudio?
- Diff
- Push
- Pull
- Resolve Conflict
- What does the “Diff” button do?
- Pulls and Pushes your files to the repo
- Opens up the repo on a web browser
- Shows you the files you have changed and what has been changed
- Shows all of the files in your R project
- What do the push and pull buttons do?
- Upload and Download changes to/from GitHub
- Show your file edits
- Create a new branch for you to work on
- Checks your files for issues
- True or False, once you have created an R project, you cannot upload it to GitHub?
- True
- False
- Which package contains functions that let you work with GitHub in R?
gitr
usethis
rgit
tidyverse
- Which function allows you to use GitHub on an R project?
use_git
use_github
to_git
to_github
- What parts of RStudio let you upload files to GitHub? (select all that apply)
- Console
- Terminal
- Git Pane
- Files Pane
- What should be placed before commands if you want to use the terminal for git?
- "git _"
- "togit _"
- "github _"
- "upload/download _"
- True or False, files need to be committed before they are uploaded to GitHub?
- True
- False