如何通過命令列從 git 上的某個帳戶注銷?
我有兩個帳戶,但我不知道我是怎么弄錯的。在嘗試了不同的方法之后,我似乎找不到從那里退出的方法。
當我推動時,我得到:
remote: Permission to yyyyyyyy/xxxxxx.git denied to ZZZZ. //<---- wrong acc
fatal: unable to access 'https://github.com/yyyyyyyy/xxxxxx.git/': The requested URL returned error: 403
我試過了:
git config --global --unset-all
git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper
git remote rm origin
git remote add origin [email protected]:<username>/<repo>.git
git push --set-upstream origin <my-branch>
rm ~/.gitconfig
但我總是得到同樣的錯誤。
謝謝!
uj5u.com熱心網友回復:
Git 沒有登錄的概念。它所擁有的是一個存盤憑證的憑證助手,在 macOS 上,它被設定為osxkeychain系統配置中的默認值。
Git FAQ解釋了如何清除憑證助手:
echo url=https://github.com | git credential reject
請注意,如果您有兩個帳戶,則為 HTTPS 處理此問題的最佳方法是在設定遠程時始終將帳戶放在 URL 中。也就是說,您的 URL 應該看起來像https://[email protected]/git/git.git或https://[email protected]/git/git.git。然后,因為您有不同的用戶名,憑證助手將為每個用戶分別存盤憑證并自動使用正確的憑證。 Git FAQ 中也概述了這種方法。
請注意,如果您需要更改現有遙控器的 URL,您可以這樣做git remote set-url origin https://[email protected]/git/git.git:
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/485399.html
