I resolved this issue by setting an email address in Git:

git config --global user.email "email@example.com"
Answer from Gregory Thomas on Stack Overflow
๐ŸŒ
Git Scripts
gitscripts.com โ€บ vscode-git-set-username-and-password
vscode Git Set Username and Password: A Quick Guide
March 6, 2026 - ... To set your Git username and password in Visual Studio Code, you can use the following commands in the integrated terminal: git config --global user.name "your_username" git config --global user.email "[email protected]"
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ how-to-add-git-credentials-in-vscode
How to Add GIT Credentials in VS Code? - GeeksforGeeks
July 23, 2025 - Step 2: When you're finished installing Git, start Visual Studio Code and verify that Git is now identified. Step 3: Start a new Terminal and configure your 'user.name' and 'user.email' in git with the help of the following commands.
Discussions

Changing the Git user inside Visual Studio Code - Stack Overflow
The username in my case is personalaccesstoken. It is in the category generic credential information. 2020-10-08T04:57:26.137Z+00:00 ... @darkKnight On the Mac, this worked for me : open the Keychain app, look for an entry called vscodevscode.github-authentication (of type "application password") ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
January 22, 2020
github - Visual Studio Code is always asking for Git credentials - Stack Overflow
I started using Visual Studio Code, and I was trying to save my test project into GitHub, but Visual Studio Code is always asking for my GitHub credentials. I have installed in my PC GitHub Desktop... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Changing the Git user inside Visual Studio Code - Stack Overflow
The user for my Git commits has changed, but I am not able to change that inside of Visual Studio Code. I changed the global settings in Git, but when I want to push or sync via Visual Studio Code ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Can't use Git because of "user.name" & "user.email" in VScode studio
Those config options live in the .gitconfig file in your home directory. If it doesn't exist, you can create it. Details on how to do that are here: https://docs.github.com/en/get-started/getting-started-with-git/setting-your-username-in-git More on reddit.com
๐ŸŒ r/git
2
0
February 21, 2023
๐ŸŒ
Levine
kb.levine.io โ€บ homelab โ€บ git โ€บ vs-code โ€บ how-to-store-git-credentials-for-vscode
How to Store Git Credentials in Visual Studio Code - All Things Worthwhile
Open VSCode and then open a terminal window within VSCode. Set credential helper to store $ git config --global credential.helper store ยท Global flag is used to associate credentials with all GitHub repos. The following is the syntax used to store credentials: $ git config credential.helper store $ git push http://example.com/repo.git Username: < type your username > Password: < type your password >
๐ŸŒ
GitHub
docs.github.com โ€บ en โ€บ get-started โ€บ git-basics โ€บ setting-your-username-in-git
Setting your username in Git - GitHub Docs
... You can change the name that is associated with your Git commits using the git config command. The new name you set will be visible in any future commits you push to GitHub from the command line.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ change-git-user-or-github-account-in-vscode
Changing the Git user or the GitHub account in VS Code | bobbyhadz
April 5, 2024 - Under Generic Credentials, click on your git credentials and update your GitHub username and password by clicking on the row and selecting Edit.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ visualstudio โ€บ version-control โ€บ git-settings
Git Settings in Visual Studio | Microsoft Learn
September 8, 2026 - You can view and modify the following settings in Visual Studio, even though they're managed by Git configuration files. ... Global Git settings correspond to preferences in Git's user-specific configuration file. Repository settings correspond to preferences in the repository-specific configuration file.
Find elsewhere
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ git โ€บ adding git credentials in vs code
Adding Git Credentials in VS Code | Baeldung on Ops
April 30, 2025 - When it asks for a password, we paste the Personal Access Token instead. Subsequently, GitHub should recognize the token in place of the usual password and successfully authenticate the user. To avoid re-entering the token, we can use the credential helper configuration steps mentioned earlier with the PAT.
Top answer
1 of 16
250

Why does Visual Studio Code ask for a password? Because Visual Studio Code runs the auto-fetch feature, while the Git server doesn't have any information to authorize your identity. It happens when:

  • Your Git repository has a https remote URL. Yes! This kind of remote will absolutely ask you every time. No exceptions here! (You can do a temporary trick to cache the authorization as the solution below, but this is not recommended.)
  • Your Git repository has ssh remote URL, but you've not copied your ssh public key onto the Git server. Use ssh-keygen to generate your key and copy it to Git server. Done! This solution also helps you never retype password on terminal again. See a good instruction by @Fnatical here for the answer.

The updated part at the end of this answer doesn't really help you at all. (It actually makes you stagnant in your workflow.) It only stops things happening in Visual Studio Code and moves these happenings to the terminal.

Sorry if this bad answer has affected you for a long, long time.


The original answer (bad)

I found the solution on Visual Studio Code document:

Tip: You should set up a credential helper to avoid getting asked for credentials every time VS Code talks to your Git remotes. If you don't do this, you may want to consider Disabling Autofetch in the ... menu to reduce the number of prompts you get.

So, turn on the credential helper so that Git will save your password in memory for some time. By default, Git will cache your password for 15 minutes.

In Terminal, enter the following:

git config --global credential.helper cache
# Set Git to use the credential memory cache

To change the default password cache timeout, enter the following:

git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)

If the original answer doesn't work

I installed Visual Studio Code and configuration same above, but as @ddieppa said, It didn't work for me too. So I tried to find an option in User Setting, and I saw "git.autofetch" = true, now set it's false! Visual Studio Code is no longer required to enter password repeatedly again!

In menu File โ†’ Preferences โ†’ User Setting: Type these:

Place your settings in this file to overwrite the default settings:

{
  "git.autofetch": false
}
2 of 16
219

This has been working for me:

  1. Set the credential helper to store:

    git config --global credential.helper store

  2. Then verify if you want:

    git config --global credential.helper

A simple example when using Git Bash quoted from here (works for the current repository only, use --global for all repositories):

git config credential.helper store
git push http://example.com/repo.git

Username: < type your username >
Password: < type your password >

[several days later]

git push http://example.com/repo.git

[your credentials are used automatically]

It will work for Visual Studio Code too.

A more detailed example and advanced usage is here.

Note: Username and passwords are not encrypted and are stored in plain text format, so use it on your personal computer only.

๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 42318673 โ€บ changing-the-git-user-inside-visual-studio-code
Changing the Git user inside Visual Studio Code - Stack Overflow
The user for my Git commits has changed, but I am not able to change that inside of Visual Studio Code. I changed the global settings in Git, but when I want to push or sync via Visual Studio Code ...
๐ŸŒ
Git Scripts
gitscripts.com โ€บ vs-code-set-git-username-and-email
VS Code Set Git Username and Email: A Quick Guide
September 28, 2025 - It involves setting parameters that determine how Git functions, including user preferences that aid in committing changes to repositories. The configuration files, primarily located in `.gitconfig`, allow you to define user-specific settings such as your username and email.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ sourcecontrol โ€บ overview
Source control in VS Code
November 3, 2021 - git config --global user.name "<your-name>" git config --global user.email "<your-email>"
๐ŸŒ
Reddit
reddit.com โ€บ r/vscode โ€บ [ removed by moderator ]
r/vscode on Reddit: [ Removed by moderator ]
December 9, 2023 - I think the most convenient option is for you to enter the following commands in the VSCode terminal: git config --global user.name "YOUR_NAME" git config --global user.email "YOUR_EMAIL" These variables are simply used to provide information ...
๐ŸŒ
Rune Hub
rune.codes โ€บ home โ€บ tutorials โ€บ vs code โ€บ how to set up git in vs code and configure your name and email
How to Set Up Git in VS Code and Configure Name & Email | Rune Hub
August 1, 2026 - ... Install Git from git-scm.com before using source control in VS Code. Configure your global name and email with git config --global user.name and git config --global user.email.
๐ŸŒ
Git Scripts
gitscripts.com โ€บ config-git-in-vscode
Config Git in VSCode: A Quick Setup Guide
April 7, 2026 - The integrated terminal allows you to execute Git commands directly without needing to switch between tools. ... Setting your user name and email is crucial, as this information will be associated with your commits. To configure these settings, run the following commands in the integrated terminal:
๐ŸŒ
Doug's Blog
dougdefrank.wordpress.com โ€บ 2019 โ€บ 07 โ€บ 26 โ€บ git-with-vs-code-for-mac-part-3
Git with VS Code for Mac: Part 3 โ€“ Configuring Git and VS Code โ€“ Doug's Blog
November 7, 2019 - Provide a description of the system youโ€™ll be connecting to your GitHub account. Then, there are a number of options to select from. For me, Iโ€™ve done repo and gist, and that seems to be enough. Then, click Generate Token. A long, alpha-numberic code will be displayed, and that will be the unique password needed to perform the authentication. Copy the code, and re-try the synchronization with your username, and the token as your password.
๐ŸŒ
The Data Farm
thedatafarm.com โ€บ tools โ€บ is-visual-studio-code-bugging-you-for-your-user-name-and-e-mail-address
Is Visual Studio Code Bugging You For Your User Name and E-Mail Address? | The Data Farm
December 22, 2015 - git config --global user.name yourname git config --global user.email youremail@address.com ยท Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Git Config User Profiles - Visual Studio Marketplace
August 23, 2026 - Extension for Visual Studio Code - Define multiple git config user profiles and switch them easily using status bar
๐ŸŒ
vGeek
vcloud-lab.com โ€บ entries โ€บ powershell โ€บ solved-visual-studio-code-make-sure-you-configure-your-user-name-and-user-email-in-git
Solved Visual studio Code make sure you configure your user.name and user.email in git | vGeek - Tales from real IT system Administration environment
Once added workspace, As no files are staged on the git system and all files and folders are untracked with U message. Press + on change and type something useful message (ie: First Initial). The next, I faced error when clicking on commit button. The error was "Make sure you configure your "user.name" and "user.email" in git." or "Git: *** Please tell me who you are", Clicking on open git log, shows Output whats going wrong.