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 i
Use an SSH key without a passphrase.
Maybe this is obvious to some (wasn't to me). It also doesn't solve the issue if you absolutely require a passphrase, but this was a decent compromise in my situation on Mac.
Following that article:
You may just set GIT_SSH env. var. to the Putty's plink.exe program. (Then use the pageant.exe as a auth. agent)
All I had to do was to run this command:
git config --global credential.helper wincred
Then I was prompted for password twice.
Next time it worked without prompting me for password.
For me I had setup my remote repo with an SSH key but git could not find them because the HOMEDRIVE environment variable was automatically getting set to a network share due to my company's domain policy. Changing that environment variable in my shell prior to launching code .
caused VSCode to inherit the correct environment variable and viola no more connection errors in the git output window.
Now I just have to figure out how to override the domain policy so HOMEDRIVE is always pointing to my local c:\users\marvhen
directory which is the default location for the .ssh
directory.
for windows 10 press windows key type cred and you should see "Credential Manager" in Control Panel click to open and then remove the related cached credentials then try again, it will ask user id password key in the correct password and you'll be good.
Happened with me when I changed my network password
After 98 upvotes, I think I need to give a true answer with the explanation.
Why does VS code ask for a password? Because VSCode runs the auto-fetch feature, while git server doesn't have any information to authorize your identity. It happens when:
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.)ssl
remote url, BUT you've not copied your ssh public key onto 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 VSCode and moves these happenings to the terminal.
Sorry if this bad answer has affected you for a long, long time.
--
I found the solution on VSCode 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)
I installed VS Code and config 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! VS Code is no longer required to enter password repeatedly again!
In menu, click File / Preferences / User Setting And type these:
Place your settings in this file to overwrite the default settings
{
"git.autofetch": false
}