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 OverflowChanging the Git user inside Visual Studio Code - Stack Overflow
github - Visual Studio Code is always asking for Git credentials - Stack Overflow
Changing the Git user inside Visual Studio Code - Stack Overflow
Can't use Git because of "user.name" & "user.email" in VScode studio
I resolved this issue by setting an email address in Git:
git config --global user.email "email@example.com"
Here are some steps to address this issue.
1. Sign out of your current account (only if you want to switch the current account)

2. Change Git settings globally

The commands are
git config --global user.email y*********@gmail.com
git config --global user.name Y*********
After completing the above steps, close and reopen Visual Studio Code. The next time you will execute your Git commands, you will be asked to login via browser, make sure you open that link in a browser where your desired GitHub account is logged in.
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
httpsremote 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
sshremote URL, but you've not copied your ssh public key onto the Git server. Usessh-keygento 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
}
This has been working for me:
Set the credential helper to store:
git config --global credential.helper storeThen 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.
How do I fix this? I've searched it up but it's not clear where to write the "config" thingy at all.