In order to get RStudio working with git and GitHub, we need to do a couple of steps.
These have to be done only once and will be forgotten soon after. ;)
Understand what git is: Section 1. - 1.7
Create a GitHub account
Post your GitHub user name within the respective course exercise submission
Updating your R and RStudio version might be a good idea if you installed them years ago
Install git (if not available): Section 6.2 - 6.4
RESTART RStudio and check if it finds git: Section 13
Configure git using RStudio and the usethis
package:
install.packages("usethis")
to get the packagelibrary(usethis)
use_git_config(..)
to register your GitHub credentials: Section 7git_default_branch_configure()
to reset main
branch name: Section 7.1.2Generate a PAT to enable RStudio-GitHub communication via usethis
package: Section 9
library(usethis)
create_github_token(description="R2 course")
credentials::set_github_pat(force_new=TRUE)
(already installed) to store the PAT: Section 9.4.1.1
Check if you can access the project on GitHub (i.e. we registered you as a collaborator already)
Once you can access the repository online, you will need to get a local copy via RStudio: Section 16.2.2
https://github.com/Dr-Eberle-Zentrum/Data-projects-with-R-and-GitHub.git
Get ready to work with it
Let’s try: Change something and Push
your changes!
hello-world.md
and say “Hi I am here” within the fileCongratulations! You have just made your first steps in a version-controlled project workflow using git!
The last three steps (check out a local copy from Github + working on it) are the standard workflow when you start your own project, using GitHub as your version-control cloud service. When working collaboratively with others or when contributing to foreign projects, the workflow needs some extensions in terms of “branches” and “pull requests”. We will look into both later in the course and master them as well!