by Losia Lagisz and Shinichi Nakagawa
Have you received and email from GitHub titled “[GitHub] Deprecation Notice“? Or you are still creating a new repositories on GitHub using https links to clone repositories into RStudio and your local computer? If so, it is time to change how you access GitHub from RStudio (and from your computer in general).
From August 13, 2021, using a password with GitHub will no longer work and token (or SSH key) authentication will be used for GitHub operations (if you are already using two-factor authentication for GotHub, you do not need to change anything). You can read official information about this change here: https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ .
It may seem quite daunting to go through all the details and options. So, below we present two main ways of switching to SSH when using GiTHUB with RStudio. First, setting public SSH key(pair) for your computer. Second, switching remote URLs from HTTPS to SSH for your existing repositories.
1. Setting public SSH key for your compute
1.1. Open RStudio and go to Preferences from the top menu. [for all Windows users, it is Tools -> Global Options (?)]
1.2. Options box appears. Press on GIV/SVN icon in the left side menu.
1.6. Still in the Options window, press on "View public key" link and copy the content of the new window box to you clipboard.
1.10. You should get an email from [GitHub] notifying you that a new public key was added to your account
1.11. Restart RStudio.
1.12. From now, when creating a new repository in GitHub use SSH code to create connect your project to your GitHub account (see https://happygitwithr.com/rstudio-git-github.html, just use SSH not https).
2. Switching remote URLs from HTTPS to SSH for your existing repositories
git remote -v
origin https://github.com/USERNAME/REPONAME.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)
This output shows what sort of url link you are currently using to connect to GitHub.
2.2. Change your remote's url from https to SSH by typing into the Terminal window (use exactly the same USERNAME/REPONAME as you got in the output of the previous step 2.1.):
git remote set-url origin firstname.lastname@example.org:USERNAME/REPONAME.git
git remote -v
The output should look like this:
origin email@example.com:USERNAME/REPOSITORY.git (fetch)
origin firstname.lastname@example.org:USERNAME/REPOSITORY.git (push)
If this approach does not work, the simple way around is to delete a local project folder from your computer and cloning it from GitHub using SSH. If you have any files and sub-folders that are not tracked by git within that folder, remember to store/archive these elsewhere before deleting the folder.
You can read more about managing remote repositories using git via Terminal here: