doc/editor_extensions/visual_studio_code/setup.md
To use the GitLab for VS Code extension, install the extension, connect to GitLab, and then configure it as needed.
Choose the installation method that meets your needs:
For added security, set up the extension and use GitLab Duo in a containerized development environment using VS Code Dev Containers.
Prerequisites:
To install the extension in a VS Code Dev Container:
Run the Dev Containers: Add Dev Container Configuration Files command from the Command Palette.
Add the GitLab extension to the configuration file:
// .devcontainer/devcontainer.json
{
"name": "My Project",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"customizations": {
"vscode": {
"extensions": [
"GitLab.gitlab-workflow"
]
}
}
}
Run the Dev Containers: Open Folder in Container command to open your project in a VS Code Dev Container. VS Code automatically installs the extension inside the container.
After you install the extension, authenticate and then connect your project to a repository on GitLab.
{{< history >}}
{{< /history >}}
{{< tabs >}}
{{< tab title="GitLab.com" >}}
Prerequisites:
api scope.To authenticate with GitLab:
GitLab: Authenticate and press <kbd>Enter</kbd>.http:// or https://. Press <kbd>Enter</kbd> to confirm.{{< /tab >}}
{{< tab title="GitLab Self-Managed and GitLab Dedicated" >}}
Prerequisites:
api scope.To use OAuth, first configure the OAuth application login:
Preferences: Open User Settings and press <kbd>Enter</kbd>.To authenticate with GitLab:
GitLab: Authenticate and press <kbd>Enter</kbd>.http:// or https://. Press <kbd>Enter</kbd> to confirm.{{< /tabs >}}
The extension matches your Git repository remote URL with the GitLab instance URL you specified for your token. If you have multiple accounts or projects, you can choose the one you want to use.
[!note] If your GitLab instance or network uses a custom SSL setup, you can configure the extension to support self-signed certificates. For more information, see using the extension with self-signed certificates.
To connect to your GitLab repository from VS Code:
In VS Code, on the top menu, select Terminal > New Terminal.
Clone your repository: git clone <repository>.
Change to the directory where your repository was cloned and check out your branch:
git checkout <branch_name>.
Ensure your project is selected:
In the terminal, ensure your repository is configured with a remote: git remote -v. The results
should look similar to:
origin [email protected]:gitlab-org/gitlab.git (fetch)
origin [email protected]:gitlab-org/gitlab.git (push)
If no remote is defined, or you have multiple remotes:
The extension shows information in the VS Code status bar if both:
To configure settings, go to Settings > Extensions > GitLab.
After you authenticate and connect to your repository, the extension automatically associates your GitLab account and project based on your Git repository configuration.
The extension uses one account for each VS Code workspace (window). It automatically selects the account when:
git remote
configuration.If multiple GitLab accounts exist and the extension cannot determine which account to use, it adds Multiple GitLab Accounts ({{< icon name="question-o" >}}) to the status bar. To select a GitLab account, select the status bar item and follow the prompts.
Alternatively, you can use the Command Palette:
GitLab: Select Account for this Workspace.The extension uses your Git repository remote to determine which GitLab project to associate with your workspace.
When your Git repository has multiple remotes that point to different GitLab projects, the extension cannot determine which one to use. For example:
origin: [email protected]:gitlab-org/gitlab-vscode-extension.gitpersonal-fork: [email protected]:myusername/gitlab-vscode-extension.gitIn these cases, the extension adds a (multiple projects) label to the status bar.
To select a project:
The Issues and merge requests list updates with your selected project's information.
To change your project selection:
GitLab Duo features are enabled by default in VS Code when you meet the prerequisites:
To turn off GitLab Duo features in VS Code:
GitLab for VS Code uses the telemetry settings in Visual Studio Code to send usage and error information to GitLab. To turn on or customize telemetry in Visual Studio Code:
all: Sends usage data, general error telemetry, and crash reports.error: Sends general error telemetry, and crash reports.crash: Sends OS-level crash reports.off: Disables all telemetry data in Visual Studio Code.