Why Git stops asking for your credentials
By default, Git stores your username and password in memory for 15 minutes after you first enter them. After that window closes, or if you restart your computer, Git forgets them. If you have set up credential caching or credential storage on your machine, Git may remember your credentials for hours or even permanently — which is why it stops prompting you.
The reason Git does this is convenience: typing your username and password for every single push or pull gets tedious fast. But if you share your computer with others, or if you want to use different accounts for different projects, you need Git to ask you every time instead of using stored credentials.
Key Takeaways
- Git stops asking for credentials when you have credential caching or storage turned on, which is the default on Windows and macOS.
- On Windows, you disable credential storage by removing your credentials from the Windows Credential Manager, not from Git itself.
- On macOS, you remove credentials from the Keychain app, then tell Git to stop using the osxkeychain helper.
- On Linux, you disable the cache helper by changing your Git config, since Linux does not store credentials by default.
- After you make the change, Git will prompt you for your username and password on your next push or pull.
Disable credential storage on Windows
Windows stores Git credentials in the Windows Credential Manager, a built-in app that holds passwords for many programs. To make Git ask for your credentials every time, you need to remove them from there.
Open the Windows Credential Manager by typing "Credential Manager" into the Windows search box and clicking the result. Look for entries that start with git: — these are your Git credentials. Click on each one and select Remove. After you delete them, Git will have nothing to retrieve and will ask you for your username and password on your next push or pull.
If you want to prevent Windows from storing new credentials in the future, open Git Bash and run this command:
git config --global credential.helper ""
This tells Git to use no credential helper at all. The next time you push or pull, Git will prompt you, and Windows will ask if you want to save the password — click No each time to keep it from storing them again.
Disable credential storage on macOS
macOS stores Git credentials in the Keychain app. To make Git ask for your credentials every time, you need to remove them from Keychain and tell Git to stop using it.
Open Keychain Access by pressing Command+Space, typing "Keychain Access", and pressing Enter. Search for git in the search box. You will see entries for your Git credentials — click on each one and press Delete. After you remove them, open Terminal and run this command:
git config --global credential.helper ""
This tells Git to stop using the osxkeychain helper. On your next push or pull, Git will ask for your username and password instead of looking in Keychain. If you want to use Keychain again later, you can run git config --global credential.helper osxkeychain to turn it back on.
Disable credential caching on Linux
Linux does not store credentials permanently by default, but if you have set up the cache helper, Git will remember your credentials for 15 minutes. To make Git ask every time, disable the cache helper.
Open a terminal and run this command:
git config --global credential.helper ""
This removes the cache helper from your global Git configuration. On your next push or pull, Git will prompt you for your username and password. If you had set the cache helper to a longer timeout — like one hour or one day — this command will override that setting.
Test that Git is asking for credentials
After you make the change, the easiest way to test it is to push or pull from a repository. Open Terminal or Git Bash, navigate to a folder where you have a Git repository, and run:
git pull
Git should now prompt you to enter your username and then your password. If it does not ask, check that you completed the step for your operating system correctly. On Windows, make sure you removed the credentials from Credential Manager. On macOS, make sure you removed them from Keychain and ran the config command. On Linux, make sure you ran the config command to remove the cache helper.
Use a personal access token instead of your password
If you are using GitHub, GitLab, or Bitbucket, you can make Git ask for a personal access token instead of your actual password. A token is a long string of characters that acts like a password but can be revoked or limited to specific actions without changing your real password.
On GitHub, go to Settings > Developer settings > Personal access tokens > Tokens (classic), click Generate new token, and give it permission to access repositories. Copy the token, then when Git asks for your password, paste the token instead. You can revoke the token anytime without affecting your account password.
Using a token is safer than storing your real password, especially if you share your computer or use Git on multiple machines. If someone gets the token, you can delete it without locking yourself out of your account.
Frequently Asked Questions
Will Git ask me every single time if I disable credential storage?
Yes. Every time you push, pull, or fetch, Git will prompt you for your username and password. If you do this many times a day, it can get repetitive. Consider using a personal access token instead, which you can copy and paste faster than typing a password.
What if I want to use different accounts for different projects?
Disabling credential storage is one way to do this, but a better approach is to set up SSH keys for each account or use a personal access token for each project. This way you do not have to type credentials at all, and Git knows which account to use based on the repository URL.
Can I make Git ask for credentials only for certain repositories?
Yes. Instead of running git config --global, you can run git config --local inside a specific repository folder. This changes the setting only for that repository, while other repositories keep their credential storage.
What happens if I close Terminal before Git finishes asking for my password?
Git will cancel the operation and not push or pull anything. You can run the command again and Git will ask for your credentials once more.