Git does not remember username and password on Windows
Git does not remember username and password…!
I was having issues, where Git would not remember my credentials for some repositories on Windows. Usually, the repositories are stored on AzureDevops and use Windows Authentication as default, with PAT (Personal Access Token) as a fallback.
In this case, since I am not an employee in the company, I was given a PAT. But git kept asking me to enter credentials for every operation against the repository origin and it was making me crazy that it was not remembering my credentials.
Make sure that you are using Windows Credentials manager
If you are using Git on Windows, you should store your credentials in the Windows Credentials manager, so they are properly encrypted and protected.
You can check this by running the following command in CMD or Powershell:
git config --list
It will then list all settings for git. You are looking for the
credential.helper which should be equal to
... color.interactive=true help.format=html credential.helper=manager user.name=André Snede Kock email@example.com
Set credential helper
If it is not set, or you want to make sure it is. Run the following command to set the config on a global level.
git config --global credential.helper manager
And if you want a complete sanity check, you can unset it first via:
git config --global --unset credential.helper
Manually set the credentials in the Windows Credential Manager
Go to the Windows Credential manager, either by searching for it in Start:
Or finding it via the Control Panel -> Manage Windows Credentials.
Go to Windows Credentials -> Generic Credentials.
Here your credential should be listed if everything is working correctly. Git should add it by default the first time you log in to a new repository. But sometimes it doesn’t work.
Luckily for us, we can add our credential manually.
Check if your git repository credential is not already listed
A correct listing for github will look like the following:
Note that the internet or network address includes a
git: statement, this is important!
If you have an incorrect listing, remove it before continuing.
Manually add credential
In the Generic credentials listing, click “Add a generic credential”. This will take you to a new page, where you enter a url, username and password.
Make sure you remember to add “git:” to the start of the url.
That’s it! Now git should use these credentials by default.
You can now run
git pull or git clone https://snede.visualstudio.com
To test if it works. Depending on whether you have already downloaded the repo before.
Now git should remember your username and password, for that repository anyways.
Git does not automatically remember username and password, when the repository is using Windows Credentials for some reason.
If the username is already added and the above approach is not working, or not available to you, you can use the “run command” and open the key manager this way. This window is usually used for handling passwords in an automated way.
Windows Key + R – To Get the “Run” window up.
// André Snede Kock