usethis
install.package("usethis")
First, git
needs to know who you are so your commits can be attributed to you. usethis
to the rescue again!
Check your configuration
usethis::use_git_config()
Set your configuration
Use your GitHub username and and the email you used to sign-up on GitHub
usethis::use_git_config(
user.name = "Jane",
user.email = "jane@example.org")
To authenticate with GitHub through the GitHub API (for example when you want to create a repo programmatically), you’ll also need a Personal Authorisation Token (PAT).
usethis::browse_github_pat()
will open up the GitHub panel to generate your PAT.
Copy it and paste it into your .Renviron
file as system variable GITHUB_PAT
.
usethis::edit_r_environ()
Use edit_r_environ()
to open and edit your .Renviron
file
To avoid having to type in your GitHub username and password every time you want to push an edit when using Rstudio interactively, you can set up an SSH RSA key
On the top toolbar of your Rstudio, click “Tools” and select “Global Options…” from the dropdown menu
Once you’ve created your SSH RSA key pair, you need to add the public key to GitHub. To do so, in Rstudio, click on View public key (see image above) and copy the text in the pop up tab.
Navigate to GitHub, click on your profile avatar on the top right corner and, on the drop down menu, select Settings
Navigate to the SSH and GPG key tab on the left hand side menu and click on New SSH key
In the new SSH key tab that opens, give the key a title that indicates the machine your private key is stored on and paste the SSH key in the key field