How do you reset the stored credentials in 'git credential-osxkeychain'?

nirvana picture nirvana · Jun 17, 2012 · Viewed 161.8k times · Source

I've followed the GitHub instructions for setting up my account, and I'm able to clone, but I'm unable to push remotely.

When I do a "git push" I get the 403 error. It has the correct URL. I tried a "git credential-osxkeychain get" to see what it was giving, and this prints out the wrong credentials.

I believe what happened is the first time it asked for the credentials, I thought it was another application asking, and it put the wrong ones in.

I just need to reset it so that it uses the correct keychain item for my GitHub account.

I've tried:

git credential-osxkeychain erase
git credential-osxkeychain set

The program never gives any prompts. Set will say "bad input" if I don't do the right thing. I tried putting in "password=password", etc., but then when I do a "get" I still get the old ones.

I can't figure out where these are being stored, as they are not in .gitconfigure. Further there are no recent keychain items that could be it. (I have several GitHub accounts in my keychain and it is not using any of them.)

Answer

maz picture maz · Jan 18, 2015

From Terminal: (You need to enter the following three lines)

 $ git credential-osxkeychain erase ⏎
 host=github.com  ⏎
 protocol=https   ⏎
 ⏎
 ⏎

NOTE: after you enter “protocol=https” above you need to press ~~RETURN~~ TWICE (Each '⏎' is equivalent to a 'press enter/return' )