How do I update the password for Git?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
To update your Git password, you need to update or clear the stored credentials in whatever credential helper your system uses. On macOS that is Keychain Access, on Windows it is Windows Credential Manager, and on Linux it is typically the store or cache helper. After clearing or updating the stored credential, the next Git operation that requires authentication will prompt you for the new password or personal access token.
Note that GitHub, GitLab, and Bitbucket have all moved away from plain passwords for HTTPS authentication. If you are using one of these services, your "password" is almost certainly a personal access token (PAT), not your account login password. Updating it follows the same credential-helper workflow described below.
Step 1: Identify Your Credential Helper
Before you can update anything, find out how Git is storing your credentials.
Common outputs and what they mean:
| 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, Git has no credential helper and will prompt on every authenticated operation. In that case, there is nothing to update since no credentials are stored.
Step 2: Update Credentials by Platform
macOS (osxkeychain)
The simplest approach is to delete the old credential and let Git prompt you for the new one.
You must press Enter after protocol=https and then press Enter again on a blank line to send the input. After this, the next git push or git pull will prompt for your username and token.
Alternatively, open Keychain Access, search for github.com (or your Git host), and update the password field directly.
Windows (Credential Manager / GCM)
Open the Windows Credential Manager through Control Panel:
- 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.
You can also remove the credential from the command line and let Git re-prompt:
If you are using Git Credential Manager (GCM), it may open a browser-based OAuth flow on the next push instead of a terminal prompt.
Linux (store helper)
The store helper saves credentials in plain text at ~/.git-credentials. You can edit the file directly.
Each line follows this format:
Replace the old token with the new one. If you prefer to start fresh:
The next authenticated Git operation will prompt for credentials and recreate the file.
Linux (cache helper)
The cache helper stores credentials in memory with a configurable timeout. To force a re-prompt, clear the cache:
After this, the next Git operation will ask for credentials again.
Step 3: Verify the Update
After updating your credentials, confirm they work:
If authentication succeeds, you will see a list of refs. If it fails, Git will either prompt again or return an authentication error, which means the token or password you entered is incorrect.
Switching from Password to Personal Access Token
Most major Git hosts now require personal access tokens instead of passwords for HTTPS operations. If you are still being asked for a "password" at the terminal, you should enter your PAT, not your account password.
To generate a PAT 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, the path is Settings > Access Tokens. On Bitbucket, it is Personal Settings > App passwords.
Switching to SSH Instead
If managing HTTPS tokens feels cumbersome, SSH keys eliminate password and token management entirely for Git operations.
Add the public key to your Git host's SSH key settings. Then update your remote URL:
After this, Git authenticates via your SSH key and never asks for a password or token.
Credential Helper Comparison
| 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 |
Common Pitfalls
Entering your account password instead of a PAT. GitHub deprecated password authentication for HTTPS in August 2021. If you type your GitHub login password, authentication will fail. Use a personal access token instead.
Forgetting to press Enter on a blank line when using git credential-osxkeychain erase. The command reads from stdin and expects a blank line to terminate input. Without it, the command hangs waiting for more input.
Editing ~/.git-credentials with a text editor that adds trailing whitespace or newlines. Invisible characters can corrupt the credential file. Use a reliable editor or delete the file entirely and let Git recreate it.
Updating credentials globally when you use different accounts for different repositories. If you contribute to repos under multiple GitHub accounts, set credentials per-repository rather than globally. Use git config --local credential.helper inside each repo.
Not revoking old tokens after rotation. Updating your local credential does not invalidate the old token on the server. Always revoke the previous token from your Git host's settings after generating a new one.
Summary
Updating your Git password or token is a credential-helper operation, not a Git configuration change. Identify your credential helper with git config --get credential.helper, then clear or update the stored credential through the appropriate mechanism for your OS. Verify the update with git ls-remote. For long-term convenience, consider switching to SSH keys or using Git Credential Manager, which handles token refresh and OAuth flows automatically. Always revoke old tokens on the server side after rotating credentials locally.
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 courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.