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

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.)

This question is related to macos git github

The answer is


Try running /Applications/Utilities/Keychain Access.


On Mac, use the command git credential-osxkeychain erase.

OR remove manually from keychain from Applications ? Utilities ? Keychain Access. Then remove the github.com keychain. Then use push; it will ask for the keychain access; then deny.

It will ask for the new username and password, add it then pushes a file for that.

After git push I found this error. Then I use the upper case- issue:

remote: Permission to user1/file.git denied to user2(previously exist user ). fatal: unable to access 'https://github.com/xxxxxxxxxxxx/': The requested URL returned error: 403


git-credential-osxkeychain stores passwords in the Apple Keychain, as noted above.

By default, gitcredentials only considers the domain name. If you want Git to consider the full path (e.g. if you have multiple GitHub accounts), set the useHttpPath variable to true, as described at http://git-scm.com/docs/gitcredentials.html. Note that changing this setting will ask your credentials again for each URL.


Try this in your command line.

git config --local credential.helper ""

It works for me every time when I have multiple GitHub accounts in OSX keychain



I'm not sure how to erase through the command line, but it's fairly easily to do it through the Keychain Access app. Just go to Applications -> Utilties -> Keychain Access, then enter "github.com". You can either delete the invalid item or update the password from with the app.


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' )


Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch