Linking RStudio to your GitHub account

To be able to use GitHub functionalities in RStudio, including through the terminal, you need to setup your GitHub credentials within the RStudio terminal.

1 Setting up RStudio

Make sure GitHub Desktop is installed, then in RStudio

go to Tools > Global Options > Git/SVN and fill in the Git executable field with the location of your git executable (git.exe for Windows users)

Create a repo

2 Generate a GitHub token

Log on to GitHub.com and access your personal settings:

Go to developer settings

Select “Tokens (classic)” under “Personal access tokens”

Then Select “Generate new token (classic)

Fill in the different elements :

  • Note : give a brief description of your token, i.e. RStudio token
  • Expiration : Define the expiration date of this token (after which your credentials will be revoked and you will have to redo the linking procedure, including setting up a new token)
  • Select scopes : Tick the scope of application of this token, this means what the application linked to your github account with this token can do. For RStudio, since we do advance branch management I would select all except admin:gpg_key and admin:ssh_signing_key

Click on generate token and the following message will appear :

For example only: the token generated here is in the green line : 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

Copy and save your generated code somewhere safe.

3 Procedure to connect to GitHub in the RStudio terminal

In the terminal (ie NOT the console)

Terminal
git config --global user.email "githubloginemail"
## replace githubloginemail by your email used to log in to your github account
git config credential.helper store