Where Git stores your credentials and how to view them
Git credentials are stored in different places depending on how you set up authentication. On most systems, Git uses a credential helper — a program that remembers your username and password or token so you don't type them every time. To see what's stored, you need to know which helper your Git installation is using, then access the right file or system.
The most common storage locations are a plain text file in your home directory (usually .git-credentials), the macOS Keychain, Windows Credential Manager, or a system service like pass on Linux. Each one requires a different command to view what's inside.
Key Takeaways
- Check which credential helper you're using by running git config --global credential.helper in your terminal.
- If you use the store helper, your credentials are in a plain text file at ~/.git-credentials that you can open with any text editor.
- macOS Keychain and Windows Credential Manager store credentials in encrypted system vaults that require separate tools to view.
- Never share the output of credential commands with anyone, and consider switching to a token-based system instead of storing passwords.
Finding which credential helper you're using
Open your terminal and run this command:
git config --global credential.helper
This tells you which helper is active. If nothing prints, Git is not storing credentials automatically — you're typing them each time, or using SSH keys instead. If it prints store, cache, osxkeychain, wincred, or another name, that's your helper.
You can also check if a helper is set only for a specific repository by running the same command without --global while inside that repository folder. A repository-level setting overrides the global one.
Viewing credentials stored with the store helper
If your helper is store, credentials live in a plain text file. Open your terminal and run:
cat ~/.git-credentials
This prints the file contents to your screen. Each line shows a URL with your username and password or token embedded in it, in the format https://username:password@github.com. If the file doesn't exist, no credentials are stored yet.
You can also open this file in any text editor — nano ~/.git-credentials or vim ~/.git-credentials — to view or edit it. Be careful: this file contains your actual passwords in plain text, so treat it like you would treat a file with passwords written down. Never share its contents, and consider deleting it if you're not actively using the store helper.
Checking credentials on macOS with Keychain
If your helper is osxkeychain, Git stores credentials in the macOS Keychain, which is encrypted. You cannot view them directly from the terminal in a useful way, but you can check what's stored using the Keychain Access app.
Open Keychain Access (search for it in Spotlight), then look for entries with "git" in the name. You'll see items like "git:https://github.com" listed. Click one to see its details, then check the "Show password" box — macOS will ask you to confirm your login password, then display the stored token or password.
If you want to remove a stored credential from Keychain, right-click the entry and select Delete. The next time you push or pull, Git will ask for your credentials again.
Checking credentials on Windows with Credential Manager
If your helper is wincred, Git uses Windows Credential Manager. Open Credential Manager by searching for it in the Start menu, then select "Windows Credentials" on the left. Look for entries labeled "git:https://github.com" or similar.
Click an entry to expand it and see the username. To view the password or token, click "Show" — Windows will ask you to confirm your identity. If you want to remove a credential, click "Remove" and confirm.
After you delete a credential from Credential Manager, Git will prompt you for it the next time you use it.
Understanding the cache helper and other options
If your helper is cache, Git stores credentials in memory only — they disappear when you close your terminal or after a timeout (usually 15 minutes). You cannot view cached credentials from the terminal because they're not written to disk. This is more secure than the store helper because credentials don't sit in a file.
If you're using a custom helper or a third-party tool like pass or secretservice, the way to view credentials depends on that tool. Check its documentation for how to list or display stored items.
Why you should consider switching to tokens instead
If you find your password stored in plain text or in a system vault, consider switching to a personal access token instead. GitHub, GitLab, Bitbucket, and other platforms let you create tokens that work like passwords but can be revoked without changing your actual account password.
To use a token, generate one in your Git platform's settings, then use it in place of your password when Git asks for credentials. You can store a token the same way you store a password — in the store helper, Keychain, or Credential Manager — but if the token leaks, you can delete it from your account settings without affecting your other logins.
To switch from password to token, delete your current credentials from storage (using the methods above), then push or pull again. Git will ask for your username and password; enter your username and paste the token as the password. Git will store the token for next time.
Frequently Asked Questions
Can I see my Git password if I forgot it?
If you stored it with the store helper, yes — run cat ~/.git-credentials to see it. On macOS or Windows, you can view it through Keychain Access or Credential Manager using the steps above. If you used a token instead of a password, you cannot recover it — you'll need to generate a new one from your Git platform's website.
Is it safe to store credentials in the store helper?
No. The store helper saves credentials in plain text, which means anyone with access to your computer can read them. Use cache (memory only), osxkeychain (macOS), wincred (Windows), or a token-based system instead. If you're already using store, delete the ~/.git-credentials file and switch to a more secure helper.
What should I do if I think my Git credentials were exposed?
Delete the credentials from storage immediately using the steps for your helper, then change your password or revoke the token on your Git platform's website. If you used a password, change it. If you used a token, delete it from your account settings — you can generate a new one anytime. Check your account's login history and recent activity to see if anyone else accessed it.
How do I stop Git from storing credentials?
Run git config --global --unset credential.helper to remove the global setting. Git will then ask for your username and password every time you push or pull. If you want to use SSH keys instead, set up an SSH key pair and configure Git to use SSH URLs for your repositories.
Can I have different credentials for different repositories?
Yes. Inside a repository folder, run git config credential.helper store (without --global) to set a helper for just that repository. You can also configure different usernames per repository using git config user.name "Your Name" and git config user.email "your@email.com" without the --global flag.