Where Git Stores Your Login Information

Git stores your username and password in one of three places depending on your setup: in a credential helper (the most common), in a config file on your computer, or in SSH keys if you use that method instead. Most people use the credential helper without realizing it — when you type your password once, Git remembers it for future pushes and pulls. Changing it means finding where that stored credential lives and replacing it.

The method you use depends on your operating system and how you originally set up Git. Windows uses the Credential Manager. macOS uses the Keychain. Linux typically stores credentials in a plain text file or uses a credential helper daemon. SSH keys, which work on all three systems, don't use a password at all — they use a pair of cryptographic files instead.

Before you start, know that you may need to change your password at the source too. If you're changing your GitHub password, GitLab password, or Bitbucket password, you'll need to update it on their website first. Git will then prompt you for the new password the next time you push or pull.

Key Takeaways

  • Your stored Git credentials live in your operating system's credential manager (Windows), Keychain (macOS), or a config file (Linux), not in Git itself.
  • The fastest fix is to delete the old credential from your system, then let Git prompt you for the new one on your next push or pull.
  • If you use SSH keys instead of passwords, you don't need to change anything in Git — you only update the key on your Git hosting site.
  • Changing your password on GitHub, GitLab, or Bitbucket does not automatically update Git on your computer; you must remove the old stored credential first.
  • If you see "fatal: Authentication failed", your stored password is outdated and needs to be removed from your system's credential storage.

Removing Stored Credentials on Windows

On Windows, Git credentials are stored in the Windows Credential Manager, a built-in system tool. To remove an old credential, open Credential Manager by typing "Credential Manager" into the Windows search bar and selecting "Credential Manager" from the results. Click "Windows Credentials" in the left sidebar.

Look for an entry that mentions your Git hosting service — you'll see something like "git:https://github.com" or "git:https://gitlab.com". Click on it to expand it, then click "Remove". Confirm the deletion. The next time you push or pull from that repository, Git will prompt you to enter your new username and password. Type them in, and Windows will offer to save them again.

If you have multiple Git accounts (one for work, one for personal projects), you may see several entries. Remove only the one for the account you're changing. If you're not sure which is which, you can check by looking at the URL — it will show the full path to the repository.

Removing Stored Credentials on macOS

On macOS, Git credentials are stored in the Keychain, Apple's password manager. Open Keychain Access by pressing Command+Space, typing "Keychain Access", and pressing Enter. In the search box at the top right, type the name of your Git hosting service — "github", "gitlab", or "bitbucket".

You'll see entries labeled something like "github.com" or "git-credential-osxkeychain". Right-click on the entry you want to remove and select "Delete". You can also double-click it to see the full details before deleting. Once it's gone, the next time you push or pull, Git will ask for your new username and password, and macOS will ask if you want to save it to Keychain.

If you have trouble finding the entry, try searching for just "git" instead. Keychain sometimes stores these entries under different names depending on how you originally set up Git.

Removing Stored Credentials on Linux

On Linux, the method depends on which credential helper you're using. The most common is the plain text store, which saves credentials in a file at ~/.git-credentials. Open a terminal and type cat ~/.git-credentials to see what's stored. You'll see lines that look like https://username:password@github.com.

To remove a credential, open the file in a text editor by typing nano ~/.git-credentials. Find the line for the account you're changing and delete it. Press Ctrl+O to save, then Ctrl+X to exit. The next time you push or pull, Git will prompt you for your new credentials and add them back to this file.

If you're using a credential helper daemon (you can check by typing git config --global credential.helper), the process is different. For the "cache" helper, credentials expire after 15 minutes by default, so you may not need to do anything. For other helpers like "pass" or "secretservice", refer to that tool's documentation to remove the stored entry.

Using SSH Keys Instead of Passwords

If you want to avoid storing passwords altogether, you can use SSH keys. An SSH key is a pair of files — one public, one private — that Git uses to prove who you are without ever sending a password. You generate the key pair on your computer, upload the public key to GitHub (or GitLab or Bitbucket), and Git uses the private key to authenticate.

To generate an SSH key, open a terminal and type ssh-keygen -t ed25519 -C "your-email@example.com". Press Enter to accept the default file location. When prompted for a passphrase, you can leave it blank or enter one for extra security. The key pair is now in ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public).

Next, copy the public key by typing cat ~/.ssh/id_ed25519.pub and copying the output. Go to your Git hosting site (GitHub, GitLab, or Bitbucket), find the SSH keys section in your account settings, and paste the public key there. From then on, Git will use the SSH key instead of asking for a password. You never need to update it unless you lose the private key or want to revoke access from a specific computer.

Updating Your Password at the Source

If you changed your password on GitHub, GitLab, Bitbucket, or another Git hosting site, Git on your computer won't know about it automatically. The old stored credential will still be there, and Git will try to use it on your next push or pull. You'll see an error like "fatal: Authentication failed" or "remote: Invalid username or password".

When this happens, remove the old credential using the steps above for your operating system. Then try to push or pull again. Git will prompt you for your username and new password. Enter them, and your system will store the new credential for next time.

If you changed your password but haven't pushed or pulled yet, you can skip the error by removing the credential proactively. This way, Git will ask for the new password on your next action, and everything will work smoothly.

Checking What Credential Helper You're Using

If you're not sure where your credentials are stored, you can ask Git directly. Open a terminal and type git config --global credential.helper. This will print the name of your credential helper — "manager" on Windows, "osxkeychain" on macOS, or "cache", "store", or another name on Linux.

If nothing prints, Git is using the default for your system. On Windows and macOS, there's always a default. On Linux, if nothing prints, credentials are probably stored in the plain text file at ~/.git-credentials.

You can also check your Git config file directly by typing cat ~/.gitconfig (or cat ~/.config/git/config on some Linux systems). Look for a section that starts with [credential] — that will tell you which helper is active.

Frequently Asked Questions

Do I need to change my Git password if I only changed my GitHub password?

Yes. Changing your password on GitHub's website does not change what Git has stored on your computer. Git will still try to use the old password on your next push or pull, and it will fail. You must remove the old credential from your system so Git prompts you for the new one.

What if I don't remember my old password?

You don't need it. Just remove the old credential from your system using the steps for your operating system. Git will prompt you for your new password (or new username and password) the next time you push or pull. You only need the old password if you're trying to log into the website itself.

Can I have multiple Git accounts on the same computer?

Yes. Each account's credential is stored separately in your credential manager or config file. You can remove one without affecting the others. If you switch between accounts frequently, consider using SSH keys instead — you can add multiple SSH keys to your account, one for each computer or project.

Why does Git keep asking for my password even after I enter it?

This usually means your credential helper is not configured correctly, or the stored credential is corrupted. Check which helper you're using with git config --global credential.helper. If it's blank on Windows or macOS, you may need to set it up. On Linux, make sure the file at ~/.git-credentials exists and is readable.

Is it safe to store my password in a plain text file?

It's safer than retyping it every time, but less safe than using SSH keys. If you're concerned, use SSH keys instead — they don't require storing a password at all. If you do use the plain text store on Linux, make sure the file permissions are set to 600 (readable and writable only by you) by typing chmod 600 ~/.git-credentials.