Using Git with VS Code
Using the built-in Git tools
VS Code comes with integrated source control management to work with remote Git repositories, commit code, and more. To learn more about how to use git and source control in VS Code you can read their documentation.
A particularly useful extension is Git Graph. It creates a visual and interactive graph of your git repository. The extension also allows you to perform common git operations without the need to use the terminal.
For more on installing recommended extensions see Using Extensions.
Using the terminal
Users can work with Git via a terminal in VS Code. To open a terminal using the Command Palette:
- Press Cmd + Shift + P on macOS or Ctrl + Shift + P on Windows and Linux.
- Then, type “Terminal: Create New Terminal” and press Enter.
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.