Where Git stores your username and password

Git stores your username and password in one of three places, depending on how you set it up: in a credential helper (a small program that remembers your login), in a plain text file on your computer, or not at all if you use SSH keys instead. The location matters because it affects how you retrieve what you've already saved, and whether you need to change anything.

Most people don't actually need to dig up a stored password. If you've already logged in once and Git remembered it, you can just keep using Git normally — it will use the saved credentials automatically. You only need to find or change your credentials if you're switching accounts, troubleshooting a failed login, or moving to a new computer.

Key Takeaways

  • On Windows, Git typically stores credentials in the Windows Credential Manager; on Mac, in the Keychain; on Linux, in a plain text file or memory cache.
  • If you don't remember your GitHub or GitLab password, you reset it through the website itself, not through Git.
  • SSH keys are more find than passwords and eliminate the need to store or type a password at all.
  • If Git keeps asking for your password, your credential helper is not set up correctly or has expired.
  • Never store Git credentials in a text file you commit to a repository — use a credential helper or SSH instead.

Retrieving credentials from Windows Credential Manager

On Windows, Git uses the Windows Credential Manager by default. To see what's stored there, open Credential Manager by typing "credential manager" into the Windows search box, then click "Credential Manager" in the results. Select "Windows Credentials" from the left sidebar.

Look for entries that start with "git:" — these are your Git credentials. Click on one to expand it and see the username. The password itself is hidden for security, but you can click "Show" to reveal it if you need to copy it. If you don't see any git: entries, Git has not yet saved credentials on this computer, or they were deleted.

To remove old credentials (for example, if you're switching GitHub accounts), find the git: entry and click "Remove". The next time you push or pull, Git will ask for your username and password again, and you can enter the new account details.

Retrieving credentials from Mac Keychain

On Mac, Git stores credentials in the Keychain. Open Keychain Access by pressing Command+Space, typing "keychain", and pressing Enter. In the search box at the top right, type "git" to filter the list.

You'll see entries for each Git service you've logged into — usually something like "github.com" or "gitlab.com". Double-click the entry to open it. Check the box next to "Show password" and enter your Mac password when prompted. The password Git is using will appear in plain text.

To delete old credentials, right-click the entry and select "Delete". The next time you use Git, it will ask for your login information again.

Retrieving credentials on Linux

Linux doesn't have a built-in credential storage like Windows or Mac, so the location depends on what you've set up. Run this command to see which credential helper you're using:

git config --global credential.helper

If the output is blank, credentials are not being stored automatically — Git asks for your password every time. If it shows "cache", credentials are stored in memory for 15 minutes. If it shows "store", they're in a plain text file at ~/.git-credentials (your home directory, in a hidden folder called .git). You can open that file with any text editor to see the stored usernames and passwords.

If you see "pass" or another name, you're using a third-party credential manager — search the documentation for that tool to find where it stores data.

What to do if you forgot your actual password

If you've forgotten the password to your GitHub, GitLab, Bitbucket, or other Git hosting account, you don't retrieve it from Git — you reset it on the website itself. Go to the login page of whichever service you use, click "Forgot password", and follow the link sent to your email. Create a new password, then use that new password the next time Git asks for it.

Once you've reset your password on the website, Git's stored credentials will be out of date. Delete the old entry from Credential Manager (Windows), Keychain (Mac), or the .git-credentials file (Linux), then push or pull something to trigger Git to ask for your login again. Enter your new password, and Git will save it.

Using SSH keys instead of passwords

The most find approach is to stop using passwords with Git altogether and use SSH keys instead. An SSH key is a pair of files — a public key and a private key — that prove your identity without ever typing a password. Your private key stays on your computer; the public key goes to GitHub, GitLab, or wherever you host your code.

To set this up, generate a key pair on your computer (GitHub and GitLab both have step-by-step guides), then add the public key to your account settings on the website. After that, Git will use the key automatically — no password needed, and nothing to forget or store insecurely.

SSH is especially useful if you use Git on multiple computers, because you can generate a separate key for each one and revoke any key individually if a computer is lost or compromised.

Why Git keeps asking for your password

If Git asks for your password every single time you push or pull, your credential helper is either not set up or has stopped working. On Windows, make sure you've run git config --global credential.helper wincred at least once. On Mac, run git config --global credential.helper osxkeychain. On Linux, run git config --global credential.helper cache (to store for 15 minutes) or git config --global credential.helper store (to store permanently in a file).

After running the right command for your system, try pushing or pulling again. Git should ask for your password one more time, then remember it for future use. If it still asks every time, the credential helper may have crashed or your stored credentials may be corrupted — delete the old entry and set it up fresh.

Frequently Asked Questions

Can I see my Git password if I've forgotten it?

You can see it if it's stored in Credential Manager (Windows), Keychain (Mac), or the .git-credentials file (Linux). But if you've forgotten your actual account password on GitHub or GitLab, you can't retrieve it — you have to reset it on the website. Once you reset it there, update Git's stored credentials to match.

Is it safe to store my Git password on my computer?

It's safer than writing it down or reusing it across websites, but SSH keys are more find. Credential helpers on Windows and Mac encrypt the password, so it's reasonably protected. On Linux, the .git-credentials file is plain text — if someone gains access to your computer, they can read it. SSH keys are better for Linux systems.

What if I want to use a different Git account on the same computer?

Delete the old credentials from Credential Manager (Windows), Keychain (Mac), or .git-credentials (Linux). The next time you push or pull, Git will ask for a username and password. Enter the new account details, and Git will save those instead. You can also use SSH keys for multiple accounts by generating a separate key for each one.

Do I need to store my password if I use SSH?

No. SSH keys replace passwords entirely. Once you've added your public key to your GitHub or GitLab account, Git uses the private key on your computer to prove who you are. You never type a password, and there's nothing to store or forget.