usethis::use_git_config(user.name = "Your Name", user.email = "you@example.com")10 Git in RStudio (Setup & Auth)
10.1 One-Time Setup
- Install Git and ensure
git --versionworks. - In R:
10.2 Initialize Git for the Current Project
usethis::use_git()10.3 Connect to GitHub
- Create a GitHub account.
- In R:
usethis::create_github_token()
gitcreds::gitcreds_set() # paste token when prompted
usethis::use_github(protocol = "https")Or set up SSH keys via RStudio (Tools > Global Options > Git/SVN).
10.4 Typical Workflow
- Stage changes (Git pane in RStudio).
- Commit with a clear message.
- Push to origin (GitHub).
10.5 Remove Git from a Project (macOS/RStudio)
- In Finder/Terminal, delete the hidden
.gitfolder in the project root (careful!). - Or from Terminal at project root:
rm -rf .git
- Reopen project in RStudio; Git pane will disappear.
Exercises - Create a new repo for this Quarto course and push it. - Branch, make a change, open a Pull Request on GitHub.