#Git

1 messages · Page 1 of 1 (latest)

digital zealot
#

I accidentally connected a wrong GitHub account1 and now every push to my account2 repo gets denied with 403, even though Keychain has no stored credentials and the remote URL is correct. How do I completely remove the account1 session and force Git to use account2?

raw sphinxBOT
#

<@&987246964494204979> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
I accidentally connected a wrong GitHub account1 and now every push to my account2 repo gets denied with 403, even though Keychain has no stored credentials and the remote URL is correct. How do I completely remove the account1 session and force Git to use

This issue usually occurs because Git is still using cached credentials or your system is sending the wrong authentication token for the remote repo, despite no visible credentials in Keychain.

To resolve:

  • Clear cached Git credentials:
    Even if Keychain is empty, Git might have credentials cached in other credential helpers. Run:

    git credential-cache exit
    
  • Check Git credential helper config:
    Run:

    git config --global credential.helper
    

    If it returns something like osxkeychain, ensure your Keychain is truly cleared. You can also temporarily disable it by:

    git config --global --unset credential.helper
    
  • Force Git to prompt for new credentials:
    Try pushing using HTTPS and explicitly specify your username:

    git remote set-url origin https://[email protected]/your-username/your-repository.git
    git push
    

    It should prompt for the password or personal access token.

  • Use a Personal Access Token (PAT):
    GitHub no longer supports password authentication. If you’re using a password, replace it with a PAT.

  • Clear SSH keys (if using SSH):
    Make sure SSH keys used belong to the correct GitHub account.


Useful links: