简体   繁体   中英

Reset git credentials (Github)

I have two Github accounts: private and for work. Each associated with different credentials. Let's name these credentials PRIVATE and WORK .

Currently, my system seems to be using the work-related credentials WORK . When I tried to delete/change these credentials and push to my private repo, I still get:

git push --set-upstream origin main
ERROR: Permission to my_private_repo denied to WORK.
fatal: Could not read from remote repository.

I'm using Mac, deleted all git-related items from Keychain. When I do

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

the terminal hangs.

Can you please tell me how to completely remove the WORK credentials from the computer?

First, do check your remote URL is indeed an HTTPS one (if it is SSH, no amount of keychain fiddling would matter, since the ketchain is used to cached HTTPS credentials).

cd /path/to/repository
git remote -v

Second, for an HTTPS URL, deleting the credentials would be:

printf "host=github.com\nprotocol=https\nusername=YourWorkLogin" | git credential-osxkeychain erase

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM