7.4 Connecting Rstudio to Github

Here we verify that RStudio can issue Git commands on your behalf. Assuming that you’ve gotten local Git to talk to GitHub, this means you’ll also be able to pull from and push to GitHub from RStudio.

7.4.1 Introduce yourself to Git

The usethis package offers an approach to set your Git user name and email from within R as well as setting up a personal access token. To configure git:

## install if needed (do this exactly once):

use_git_config(user.name = "Jane Doe", user.email = "jane@example.org")

Check what you just did usethis::git_sitrep()generates a git situation-report. It can help you confirm things will work as expected; it can also help you diagnose problems:


git_sitrep() Optional: configure Git’s editor

Another Git option that many people eventually configure is the editor. This will come up if you use Git from a shell. At some point, you will fail to give Git what it wants in terms of a commit message and it will kick you into an editor. This can be distressing, if it’s not your editor of choice and you don’t even know how to save and quit. You can enforce your will by executing this in R:


use_git_config(core.editor = "nano")