How do I update the password for Git?
Categories:
How to Update Your Git Password

Learn how to update your Git password across different operating systems and credential helpers, ensuring secure and seamless repository access.
Updating your Git password is a common task, especially if you're using a credential helper or if your Git hosting provider requires a password change. This article will guide you through the process for macOS, Windows, and Linux, covering various scenarios from command-line updates to managing credential helpers.
Understanding Git Credential Helpers
Git credential helpers are programs that store your authentication credentials (like usernames and passwords) in a secure way, so you don't have to enter them every time you interact with a remote repository. When you update your password, you often need to clear or update the stored credentials in these helpers. Common helpers include osxkeychain for macOS, manager-core or wincred for Windows, and various options for Linux.

Git Credential Update Flow
Updating Git Password on macOS
On macOS, Git typically uses the osxkeychain credential helper, which stores your credentials in the macOS Keychain Access utility. To update your password, you'll need to remove the old entry from the Keychain.
1. Step 1
Open Keychain Access (Applications > Utilities > Keychain Access).
2. Step 2
In the search bar, type git or the name of your Git host (e.g., github.com).
3. Step 3
Locate the entry related to your Git repository (often named github.com or git:https://github.com).
4. Step 4
Right-click on the entry and select Delete.
5. Step 5
The next time you perform a Git operation (e.g., git pull or git push), Git will prompt you for your new password. Enter it, and it will be stored in the Keychain.
git credential-osxkeychain erase for specific entries, but deleting from Keychain Access is often more straightforward for visual confirmation.Updating Git Password on Windows
Windows users typically rely on the Git Credential Manager (GCM) which integrates with Windows Credential Manager. You can clear or update stored credentials directly from the Windows Control Panel.
1. Step 1
Open the Control Panel.
2. Step 2
Go to User Accounts > Credential Manager.
3. Step 3
Select Windows Credentials.
4. Step 4
Under the Generic Credentials section, look for entries related to git or your Git host (e.g., git:https://github.com).
5. Step 5
Expand the entry and click Remove or Edit to update the password.
6. Step 6
The next time you perform a Git operation, you will be prompted to enter your new password, which GCM will then store.
Updating Git Password on Linux
On Linux, the approach can vary depending on your setup. You might be using store, cache, or a more advanced credential helper like libsecret (which integrates with GNOME Keyring or KDE Wallet). The simplest method is often to clear the cached credentials.
git config --global --unset credential.helper
git config --global credential.helper store
# This will prompt for password on next operation and store it in plain text.
# For libsecret:
# git config --global credential.helper libsecret
Commands to unset and reconfigure credential helpers
1. Step 1
If you are using cache, you can clear it by restarting your terminal or running git credential-cache exit.
2. Step 2
If you previously configured store to save credentials in a file, you might need to manually edit or delete that file (e.g., ~/.git-credentials).
3. Step 3
For libsecret or similar keyring integrations, you might need to use a keyring management tool (like Seahorse for GNOME) to delete the stored entry.
4. Step 4
After clearing, the next Git operation will prompt you for your new password. Enter it, and it will be securely stored by your configured helper.
libsecret or gnome-keyring with Git to store your credentials encrypted. This avoids storing passwords in plain text.General Approach: Force Git to Prompt for Password
Regardless of your operating system or credential helper, you can often force Git to prompt for your password by making a change to your global Git configuration. This is a more universal method if you're unsure about your specific credential helper.
git config --global --unset credential.helper
# Now perform a Git operation (e.g., git pull or git push)
# Git will prompt you for your username and password.
# After entering, you can re-enable your preferred credential helper if desired.
# For example, to re-enable osxkeychain:
# git config --global credential.helper osxkeychain
Temporarily disabling credential helper to force password prompt
By unsetting the credential.helper globally, you instruct Git to forget any configured helper. The next time you interact with a remote repository that requires authentication, Git will fall back to prompting you directly for your username and password. After successfully authenticating with your new password, you can then reconfigure your preferred credential helper to store it securely.