How do I update the password for Git?
#1
I've run into an issue with Git and Bitbucket integration on my iMac. Due to a recent password change, my authentication to Bitbucket is failing when I try to push local commits. My system seems to have my old password cached, and I'm having trouble updating it. I've tried a few commands to no avail, and for some reason, the solution isn't as obvious as I thought it would be. My current configuration is using https protocol for the remote repository, and every time I attempt to `git push`, I receive this error:

Code:
Authentication failed
for 'https://______.git'

Here's what I've attempted so far without success:


And:


However, none of the above have prompted me for the new password on the next push attempt. I need to figure out how to either update the password in the keychain or some alternative method to clear the old one and replace it with the new. I've confirmed that the new password is working since I'm able to log in to Bitbucket with it through the browser. Any insights on how to solve this authentication issue would be highly appreciated.
Reply
#2
The command you're using for `git credential-osxkeychain erase` is correct, but keep in mind that it may not prompt you for the password after that command. You should run a `git push` to trigger the prompt for password entry. Also, ensuring that the credential helper is set properly is vital. You can verify your current helper with the following command:


If it returns `osxkeychain`, then that is set correctly. If not, you can set it with:


After ensuring the credential helper is set, try the erase command again. Make sure you enter the details correctly, and hit Enter after typing each line. Then attempt to push and see if it prompts for the new password.
Reply
#3
Following your instructions, the credential helper is indeed set to `osxkeychain`. However, even after retrying the erase command and ensuring all entries were correct, no prompt appeared after initiating a `git push`. I'm suspecting there might be a specific issue with the keychain itself or another cached setting that's causing the problem.
Reply
#4
In that case, you might want to directly access the macOS Keychain to remove the stored credentials for Bitbucket manually. Here's how you can do that through the Terminal:

Code:
# Open the keychain access utility
open / Applications / Utilities / Keychain\ Access.app
# Alternatively, you can use the `security`
command - line tool to delete the credentials
security delete - generic - password - l "bitbucket.org"

After deleting the credentials from the Keychain, try pushing again. Git should now ask you for the username and password. Enter the new credentials, and they should be saved for future use.
Please note that running these commands might affect all the services that are using the Bitbucket credentials stored in the Keychain.
Reply
#5
I went with the `security` command-line tool to avoid any confusion with the Keychain Access graphical interface. After executing the delete command, I tried to push to my repository again, and this time Git did prompt me to enter my username and password. I was able to successfully authenticate, and my push went through. The new password is now updated and cached as expected.
As a reference to anyone facing a similar issue in the future, here is the final set of working commands:

Code:
# Check
if the credential helper is set to osxkeychain
git config--global credential.helper
# Set the credential helper to osxkeychain
if not already set
git config--global credential.helper osxkeychain
# Delete existing Bitbucket credentials from the keychain
security delete - generic - password - l "bitbucket.org"
# Push to the repository to prompt
for new credentials
git push

Make sure to install Git and have access to the macOS Terminal to be able to run these commands. These solutions cater to the case where Bitbucket is the remote repository, and osxkeychain is the credential helper.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)