How to change or update your Git password (stored credentials)
Codemia Knowledge Hub ·
To update your Git password, update or clear the stored credential in your credential helper: Keychain Access on macOS, Windows Credential Manager on Windows, and usually the store or cache helper on Linux. The next Git operation that needs authentication then prompts for the new password or personal access token.
GitHub, GitLab and Bitbucket have all moved away from plain passwords for HTTPS. On those services your "password" is almost certainly a personal access token (PAT), not your login password. Updating it works the same way.
Step 1: find your credential helper
| Output | Platform | Storage Location |
osxkeychain | macOS | Keychain Access app |
manager or manager-core | Windows / cross-platform | Windows Credential Manager or GCM |
store | Linux (common) | Plain text file at ~/.git-credentials |
cache | Linux (common) | In-memory, expires after timeout |
| (empty) | Any | No helper configured; Git prompts every time |
If nothing is returned, no credentials are stored and Git prompts on every authenticated operation, so there is nothing to update.
Step 2: update the credential for your platform
macOS (osxkeychain)
Delete the old credential and let Git prompt for the new one:
Press Enter after protocol=https, then Enter again on a blank line to send the input. The next git push or git pull asks for your username and token.
Or open Keychain Access, search for github.com (or your Git host), and edit the password field.
Windows (Credential Manager / GCM)
- Go to Control Panel > User Accounts > Credential Manager.
- Select Windows Credentials (or Generic Credentials).
- Find the entry for your Git host, such as
git:https://github.com. - Click Edit and replace the password with your new token.
Or remove the credential from the command line and let Git re-prompt:
With Git Credential Manager (GCM), the next push may open a browser-based OAuth flow instead of a terminal prompt.
Linux (store helper)
The store helper keeps credentials in plain text at ~/.git-credentials:
Each line looks like:
Replace the old token with the new one, or start fresh:
The next authenticated operation prompts and recreates the file.
Linux (cache helper)
The cache helper holds credentials in memory with a timeout. Clear it to force a prompt:
Step 3: verify the new credential
A list of refs means authentication worked. Another prompt or an authentication error means the token or password is wrong.
Using a personal access token instead of a password
Most major hosts require a PAT for HTTPS. If the terminal asks for a "password", enter the PAT.
To create one on GitHub:
- Go to Settings > Developer Settings > Personal access tokens > Tokens (classic).
- Click Generate new token.
- Select the required scopes (at minimum,
repofor private repositories). - Copy the token and use it wherever Git asks for a password.
On GitLab, use Settings > Access Tokens. On Bitbucket, Personal Settings > App passwords.
Switching to SSH
SSH keys remove password and token handling from Git operations entirely:
Add the public key in your Git host's SSH key settings, then change the remote URL:
Git now authenticates with your key and never asks for a password or token.
Credential helpers compared
| Helper | Persistence | Security | Setup Effort |
osxkeychain | Permanent until deleted | Encrypted in Keychain | None (default on macOS) |
manager-core (GCM) | Permanent until deleted | OS credential store | Included with Git for Windows |
store | Permanent until deleted | Plain text on disk | Minimal |
cache | Temporary (default 15 min) | In-memory only | Minimal |
| SSH keys | Permanent | Private key on disk | Moderate |
Why the new password is rejected
You entered your account password, not a PAT. GitHub deprecated password authentication for HTTPS in August 2021. Use a personal access token.
git credential-osxkeychain erase is hanging. It reads stdin and waits for a blank line to end input. Press Enter on an empty line.
~/.git-credentials got corrupted. Editors that add trailing whitespace or newlines can break it. Use a reliable editor, or delete the file and let Git recreate it.
You use different accounts for different repositories. Set credentials per repository with git config --local credential.helper inside each repo instead of globally.
The old token is still valid. Updating it locally does not revoke it on the server. Revoke the previous token in your Git host's settings after rotating.
Related reading
- How do I use Amazon Cognito as user authentication for my website NOT mobile app
- How do I use basic HTTP authentication with the Python Requests library?
- How do I use the Argon2 algorithm with password_hash?
- How do I use WebRequest to access an SSL encrypted site using HTTPS?
- How do I use git bisect?
- How do I use 'git reset --hard HEAD' to revert to a previous commit?
- How do I verify that an Android apk is signed with a release certificate?
- How do parameterized queries help against SQL injection?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.