What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To connect GitLab features in VS Code, use the GitLab for VS Code extension and its built-in authentication command. The current procedure is not to paste a token into a gitlab.token setting.

You need a GitLab personal access token (PAT) with the api scope. The extension stores that credential separately from Git’s credentials, so authenticating the extension does not automatically authenticate HTTPS git push or git pull.

1. Install GitLab for VS Code

In standard Visual Studio Code:

  1. Open the Extensions view.
  2. Search for GitLab for VS Code.
  3. Install the extension published for GitLab.

The extension is still identified as GitLab.gitlab-workflow in Dev Container configurations. If you use an unofficial VS Code build, install it from the Open VSX Registry instead of the Visual Studio Marketplace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Create a GitLab personal access token

Create the token before starting the VS Code sign-in flow:

Popular on Amazon
Sale
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
  1. Sign in to GitLab.
  2. Select your avatar, then choose Edit profile.
  3. Open Access > Personal access tokens.
  4. Under Generate token, select Legacy token.
  5. Enter a token name, such as VS Code workstation.
  6. Optionally enter a description.
  7. Set an expiration date.
  8. Select the api scope.
  9. Select Generate token.

GitLab displays the token only immediately after it is generated. Copy it to a password manager or another secure location before leaving or refreshing the page. GitLab cannot show that same token again later.

Expiration rules

New personal access tokens require an expiration date. If you leave the date blank, GitLab applies an expiration date 365 days from the current date. Tokens expire at midnight UTC on the expiration date, which can be earlier or later than expected in your local time zone.

GitLab administrators can impose shorter maximum lifetimes. GitLab 17.6 added support for a configurable maximum lifetime that can be extended to 400 days, and GitLab 17.7 added personal-access-token descriptions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Add the token to VS Code

  1. Open VS Code.
  2. Go to View > Command Palette.
  3. Run GitLab: Authenticate.
  4. Choose your GitLab instance. Select GitLab.com for the hosted service.
  5. For GitLab Self-Managed or GitLab Dedicated, enter the complete instance URL, including https:// or http://. For example: https://gitlab.example.com.
  6. Select PAT as the authentication method.
  7. When prompted, choose to enter an existing token and paste the PAT you created.

The current extension flow may also offer to create a token. If you already generated one, use the existing-token option. You do not need to create a setting named GitLab Token, and the documented extension requirement is api; read_user is not listed as required for this flow.

4. Check the repository connection

After authentication, the extension uses the repository’s Git remote to associate your GitLab account with a project. Check the remote from the VS Code terminal:

Also popular on Amazon
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black | Full-size keyboard, spill-resistant, curved space bar, Windows PC and laptops compatible
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*
git remote -v

A typical result looks like this:

origin  https://gitlab.example.com/team/app.git (fetch)
origin  https://gitlab.example.com/team/app.git (push)

If the repository has no remote, add one through the Source Control view:

  1. Open Source Control.
  2. Right-click the Source Control label.
  3. Select Repositories.
  4. Select the repository’s ellipsis menu.
  5. Choose Remote > Add Remote > Add remote from GitLab.
  6. Select the appropriate remote.

Multiple accounts or projects

If you have authenticated more than one GitLab account, VS Code may show Multiple GitLab Accounts in the status bar. Run GitLab: Select Account for this Workspace from the Command Palette and choose the account for the current workspace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the repository has multiple remotes pointing to different GitLab projects, the GitLab view can show (multiple projects, click to select). In the Activity Bar, select GitLab, expand Issues and merge requests, select that message, and choose the project.

5. Authenticate Git push and pull separately

Adding a PAT to the extension authenticates GitLab’s VS Code features, such as issues and merge requests. It does not configure Git’s credentials for an HTTPS remote.

When Git prompts for HTTPS credentials, enter any non-empty value as the username and the PAT as the password. GitLab does not validate the username value. For example, this avoids putting the token directly into the repository URL:

Also popular on Amazon
Rii RK907 Ultra-Slim Compact USB Wired Keyboard for Windows/PC-Black(1PCS) | Full-size Keyboard,Silent Keys,Slim design,QWERTY Keyboard,USB-A Wired,Plug and Play for Windows and PC,Home or Office
  • Cheap Full-sized usb Keyboard: Offers 104 keys.Affordable, corded keyboard featuring slim design and full numeric keypad,Rii RK907 usb wired computer keyboard is super easy to use
  • Responsive Low-Profile Chiclet Keys,advanced tactile keys for quiet, comfortable typing,our USB keyboard is plug and play, no software needed. Just plug in the USB cord and it will be ready for use
  • Adjustable tilt legs for added comfort,Compatible with all desktops, notebooks, and PCs using Windows.Rii Keyboard provides a convenient keyboard solution for everyday home or office computing uses
  • Rii usb wired computer keyboard, it works instantly with any USB devices, no driver needed, no need to worry about interference that breaks your connection, no charging or battery consumption
  • Compatible with desktops and laptops with Windows 10, Windows 8, 7, Vista, XP, Mac OS and etc.Contact Rii for any instructions/replacement,we will help you solve any problem asap
git clone https://<username>@gitlab.example.com/group/project.git

When prompted:

Username: your-username
Password: your-personal-access-token

You can also use oauth2 as the username:

git clone https://oauth2:<your_access_token>@gitlab.example.com/group/project.git

However, avoid this form when possible. A token in a URL can be saved in .git/config in plaintext and may appear in shell history, proxy logs, or application-server logs. A credential manager or SSH key is safer for repeated Git operations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Use environment variables when VS Code storage is deleted

In disposable environments such as Gitpod or frequently recreated containers, VS Code may lose its stored authentication. Set these variables before starting VS Code:

GITLAB_WORKFLOW_INSTANCE_URL=https://gitlab.com
GITLAB_WORKFLOW_TOKEN=<your_personal_access_token>

For a Self-Managed instance, replace the first value with that instance’s full URL:

GITLAB_WORKFLOW_INSTANCE_URL=https://gitlab.example.com
GITLAB_WORKFLOW_TOKEN=<your_personal_access_token>

If both an extension token and an environment-variable token are configured for the same instance, the token configured in the extension takes precedence.

GitLab.com, Self-Managed, and Dedicated differences

GitLab installation Instance value PAT support
GitLab.com Select GitLab.com Yes; use a PAT with api
GitLab Self-Managed Enter the full URL, such as https://gitlab.example.com Yes; use a PAT with api
GitLab Dedicated Enter the full Dedicated instance URL Yes; use a PAT with api

OAuth is also available for Self-Managed and Dedicated instances beginning with GitLab for VS Code 6.47.0, released during GitLab 18.3. OAuth requires an OAuth application ID; PAT authentication does not.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Also popular on Amazon
Sale
Logitech MK120 Full Size Wired Keyboard and Mouse Combo - Black | Full size wired keyboard, optical wired mouse, USB plug-and-play, Windows only, pc and laptop compatible
  • Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
  • Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
  • Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
  • Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
  • Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable

Configure OAuth for a Self-Managed or Dedicated instance

  1. Open View > Command Palette.
  2. Run Preferences: Open User Settings.
  3. Open Settings > Extensions > GitLab > Authentication.
  4. Under OAuth Client IDs, select Add Item.
  5. Use the GitLab instance URL as the Key.
  6. Use the OAuth application ID as the Value.

Token scope: which one should you use?

Scope What it permits Suitable for the VS Code extension?
api Complete read/write API access within the token owner’s permitted reach Yes; this is the scope required by GitLab for PAT authentication
read_repository Pull and read access through Git over HTTP No; it does not provide the API access the extension needs
write_repository Pull and push access through Git over HTTP No; it does not support API authentication

A personal access token can reach resources available to your user. A group access token is limited to its group and projects, while a project access token is limited to its project. Use the narrowest token type that meets the actual requirement, but the PAT used by this extension must have the required api permission.

Troubleshooting

The PAT is rejected

  • Confirm that the token has the api scope.
  • Check that you selected the correct GitLab instance during GitLab: Authenticate.
  • For Self-Managed or Dedicated GitLab, include the URL scheme, for example https://gitlab.example.com.
  • Check the expiration date. A token expires at midnight UTC on its expiration date.
  • Generate a new token if you no longer have the original value; GitLab does not display it again.

The personal-access-token page returns 404

An administrator can disable access tokens on GitLab Self-Managed or GitLab Dedicated. When they are disabled, PAT-authenticated API requests are rejected, users cannot authenticate with PATs, and the personal-access-token page returns 404 Not Found. Contact the GitLab administrator rather than repeatedly generating credentials.

GitLab features work, but push fails

This normally means the extension authentication succeeded but Git’s HTTPS credentials did not. Re-authenticate Git when it prompts, using a non-empty username and the PAT as the password, or configure a Git credential manager. Also check the remote with git remote -v; it may point to a different GitLab host or project.

The project is not detected

Inspect the repository remote, add a GitLab remote if none exists, and resolve any account or project selection message in the GitLab Activity Bar. The extension cannot reliably choose when several accounts or GitLab remotes apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

FAQ

Where do I paste a GitLab token in VS Code?

Open View > Command Palette, run GitLab: Authenticate, choose the GitLab instance, select PAT, and enter the token when prompted. Do not paste it into an old gitlab.token setting.

Also popular on Amazon
Sale
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
  • The Lenovo 300 USB keyboard offers an intuitive and comfortable island key design with 2 5 zone layout including separate number pad
  • This full-size keyboard includes concaved key caps fitted for your fingertips
  • Spill resistant keys with a board drain help keep your PC keyboard protected and keep you productive
  • The complete ergonomic design includes an adjustable tilt to improve your typing comfort
  • OS independent – This convenient computer keyboard works with laptops desktops and any computer with a USB port

What scope does GitLab for VS Code require?

The current GitLab documentation requires the api scope for PAT authentication. A token with only read_repository or write_repository is not sufficient for the extension’s API authentication.

Does the VS Code token also authenticate git push?

No. The extension’s GitLab API authentication and Git’s remote authentication are separate. For an HTTPS remote, use the PAT as the password when Git prompts, or use a credential manager or SSH.

How long does a GitLab personal access token last?

New tokens require an expiration date. If you omit the date, GitLab uses 365 days from the current date. The token expires at midnight UTC on its expiration date, subject to administrator lifetime limits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I use a PAT with GitLab Self-Managed?

Yes. Run GitLab: Authenticate, enter the complete Self-Managed URL including https:// or http://, select PAT, and provide a token with the api scope.

The Bottom Line

Install GitLab for VS Code, create a GitLab personal access token with the api scope, then run View > Command Palette > GitLab: Authenticate and select PAT. Verify the repository’s Git remote separately, because the extension token does not automatically grant Git HTTPS push and pull access.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 2
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black | Full-size keyboard, spill-resistant, curved space bar, Windows PC and laptops compatible
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black | Full-size keyboard, spill-resistant, curved space bar, Windows PC and laptops compatible
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.39
SaleBestseller No. 5
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
Lenovo 300 USB Keyboard, Wired, Adjustable Tilt, Ergonomic, Windows 7/8/10, GX30M39655, Black
This full-size keyboard includes concaved key caps fitted for your fingertips; The complete ergonomic design includes an adjustable tilt to improve your typing comfort
$12.50
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply. Prices as of November 13, 2026 3:38 am GMT.