'VS Code: Pushing and pulling always ask for password

I'm using git in VS Code. I have a project in Azure DevOps. 3 months ago when I copied repo and pushed my first commit Git asked for my credentials. I entered username and generated password. After that everything was working fine. Starting march every time I pull or push VS Code askes for password. How can I save my password?



Solution 1:[1]

Check first what URL you are using:

cd /path/to/local/repo
git remote -v

If it is an HTTPS URL, check what credential helper you are using

git config credential.helper
xxx

(For instance, manager or manager-core)

Then check what credential is attached to dev.azure.com, the server part of your remote URL:

printf "host=dev.azure.com\nprotocol=https" | git credential-xxx get

Replace xxx with the name of the credential helper for the previous step.

This work even in a Windows CMD, provided your %PATH% has C:\Program Files\Git\usr\bin and C:\Program Files\Git\mingw64\libexec\git-core

If your credential is not stored, you can register it again with git credential-xxx store:

printf "username=<you>\npassword=<token>\nhost=dev.azure.com\nprotocol=https" | git credential-xxx store

Replace <you> with your DevOps username, and <token> with an Azure PAT (Personal Access token).

Solution 2:[2]

git config credential.helper store

Then git will remember your credential locally. That config is also local.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC
Solution 2 Ziming Song