Visual Studio Code
Git
Git credentials
authentication issues
coding tools

Visual Studio Code keeps asking for Git credentials

Codemia Knowledge Hub ·

When VS Code keeps asking for Git credentials, the editor is usually not the problem. VS Code shells out to Git, and Git authenticates through either SSH or a credential helper such as Git Credential Manager. If credentials are not stored, the remote URL does not match your setup, or the helper is misconfigured, every fetch, pull and push prompts again. The fix is to make Git's authentication path stable.

Check whether the remote uses HTTPS or SSH

bash
git remote -v

If the remote starts with https://, Git expects a username and password or, more commonly now, a personal access token. If it starts with [email protected]: or another SSH form, Git expects SSH keys. The fixes differ:

  • HTTPS usually needs a credential helper.
  • SSH usually needs a loaded private key and a working SSH agent.

Either method is fine. Problems start when the remote and the credential storage method do not match.

Fixing prompts on HTTPS remotes

For HTTPS remotes, the cleanest approach is usually Git Credential Manager:

bash
git config --global credential.helper manager

If your Git build does not include it, install Git Credential Manager first, then configure it. Trigger one authenticated operation:

bash
git fetch

Enter the credentials or token once, and the helper should store them in the system keychain or credential store. For GitHub and similar services, use a personal access token rather than your account password, since many hosts no longer allow password authentication for Git over HTTPS.

Check the current helper setting with:

bash
git config --global --get credential.helper

If it is blank, Git has nowhere to persist credentials and repeated prompts are expected.

Fixing prompts on SSH remotes

Confirm that the agent has your key and that SSH authentication works:

bash
ssh-add -l
ssh -T [email protected]

If ssh-add -l shows no identities, add your key:

bash
ssh-add ~/.ssh/id_ed25519

Then switch the remote URL to SSH if needed:

bash
git remote set-url origin [email protected]:owner/repo.git

With a valid key and agent, VS Code stops prompting because Git no longer needs HTTPS credentials.

When Git works in a terminal but not in VS Code

VS Code generally follows whatever the Git executable does, but a few editor-level issues can interfere:

  • The integrated terminal and the background Git process may run in slightly different environments. If SSH works in one shell but not inside VS Code, confirm the editor uses the same Git installation and can reach the same SSH agent or credential helper.
  • Source control extensions can confuse authentication flows. This is less common than a plain Git misconfiguration, but if prompts began after installing one, disable it temporarily and retest.
  • If you have multiple Git installations, check which binary VS Code uses in the command palette or settings.

Mistakes that keep the prompts coming

  • Expecting SSH keys to fix an HTTPS remote. Keys have no effect unless the remote URL is SSH-based.
  • Using a password where a token is required. If the helper keeps storing rejected credentials, delete the stored entry and authenticate again with the correct token.
  • Mixing accounts across repositories without separate credentials or host aliases, which leads to the wrong token being reused.
  • Blaming VS Code first. If git fetch from a normal terminal prompts every time too, the issue is Git authentication, not the editor.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design