Using Git with RStudio Pro
RStudio Pro sessions in Posit Workbench can connect to remote Git repositories hosted on GitHub, GitLab, Bitbucket, Azure DevOps, and other version control services.
This page covers how to set up Git credentials in your Workbench session. For a complete guide to the Git workflow in RStudio, including staging, committing, branching, and resolving conflicts, see Version Control in the RStudio User Guide.
Using the terminal
You can work with Git via a terminal in RStudio Pro. To open a terminal in RStudio Pro, click Tools > Terminal > New Terminal, or press Alt + Shift + T.
Setting up Git credentials
Because a Workbench session runs on a remote server, you need to set up your Git credentials from within the session, rather than on your local machine. Most Git-hosting providers support two authentication approaches: SSH keys and HTTPS with a personal access token (PAT).
From a terminal in your session, generate an SSH key pair or a PAT, then register it with your Git hosting provider. For step-by-step instructions, refer to your provider’s documentation:
| Provider | SSH keys | Personal access tokens |
|---|---|---|
| GitHub | Add a new SSH key | Manage personal access tokens |
| GitLab | Add an SSH key | Create a personal access token |
| Bitbucket | Set up SSH keys | Create an app password |
| Azure DevOps | Use SSH key authentication | Use personal access tokens |
Your Git credentials are stored to the default global cache. If your sessions use ephemeral storage, you might need to reconfigure credentials each time you start a new session or configure Git to store credentials to a local file in your persistent home directory with git config --global credential.helper 'store --file ~/.my-credentials'. Contact your administrator if you are unsure.
Azure delegated credentials
If your administrator has configured delegated Azure credentials, you can clone Azure DevOps repositories without setting up SSH keys or a personal access token.
With delegated credentials configured, clone an Azure DevOps repository from the terminal:
Terminal
git clone https://dev.azure.com/your-org/your-project/_git/your-repoWorkbench handles authentication automatically through your sign-in. For more information, see Delegated Azure Credentials in the Workbench Admin Guide.
Using the Git pane
RStudio Pro includes a built-in Git pane for staging, committing, and pushing changes without leaving the IDE. To use it:
Open or create an RStudio Project in a directory that contains a Git repository.
The Git tab appears in the Environment pane, showing changed files and common Git operations.
For the full Git pane workflow, see Version Control in the RStudio User Guide.
Additional resources
- Happy Git and GitHub for the useR: A comprehensive guide to setting up and using Git and GitHub with R, including troubleshooting common issues.