Configure Git on RStudio

How to configure your SSH key and create or configure an existing project in RStudio to be versioned with Git.

Configure Your SSH Keys

If you are using Git for the first time in RStudio, you must create your SSH key.

  1. Select Tools  Global Options from the toolbar.
    The Options panel opens.

  2. Select Git/SVN from the side menu.

  3. Click the Enable version control interface for RStudio projects option.

  4. Enter the required information.

  5. Click Create RSA Key.

    To be able to push your code into your remote Git repositories, you must add the created public key on your hosting provider. Click View public key to view and copy the key.
  6. Click Apply.

If your ssh-keygen is not available on your platform, ask your administrator to install it by running the following commands:

sudo apt-get update
sudo apt-get -y install openssh-client

Create a Project From an Existing Git Repository

  1. Select File  New Project from the toolbar.
    The New Project panel opens.

  2. Create your project from a Version Control.

  3. Choose Git as the version control system.

  4. Enter your repository information.

  5. Click Create Project.

Configure an Existing Repository

You can always configure an existing project to be versioned with Git.

  1. Select Tools  Version Control  Project Setup from the toolbar.
    The Project Options panel opens.

  2. Select Git/SVN from the side menu.

  3. Change the version control system setting from (None) to Git.

  4. Link this local Git repository to an existing remote repository by running the following command in the terminal:

    git remote add origin https://github.com/<>/my-rstudio-project.git

You can now perform your first commit.

If your remote repository has not yet been initialized, you will need to push your first commit by running the following command :

git push -u origin master