I think I'm github USER_A, but github thinks I'm USER_B. First, I check who I am:
$ git config --list
color.ui=auto
push.default=simple
user.name=USER_A
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/USER_A/MY_REPO.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
Then, I git clone my repo:
$ git clone https://github.com/USER_A/MY_REPO.git
Cloning into 'MY_REPO'...
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 0), reused 0 (delta 0), pack-reused 6
Unpacking objects: 100% (9/9), done.
Checking connectivity... done.
Then I change something, commit, and push:
$ git push
remote: Permission to USER_A/MY_REPO.git denied to USER_B.
fatal: unable to access 'https://github.com/USER_A/MY_REPO.git/': The requested URL returned error: 403
This the only thing Github says about this error.
Why does git/github think I'm pushing as USER_B?!
EDIT: based on comments, I ran this test:
$ ssh -T [email protected]
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of
known hosts.
Hi **USER_A**! You've successfully authenticated, but GitHub does not provide
shell access.
I don't have a ~/.ssh/config or /etc/ssh/ssh_config file. I'm on a Mac FWIW.
To update your credentials, go to Control Panel -> Credential Manager -> Generic Credentials. Find the credentials related to your git account and edit them to use the updated passwords as per the image below: I hope this helps with your Git issues.
I found the problem, my Mac keychain had USER_B. I found it when I searched for "github" in the Keychain app. I've updated the question to reflect this is a Mac-specific problem/solution.
I had the same problem. I was able to find out what key has been used by git using following command:
ssh -v -T [email protected]
Then, I saw another key is being used by github; So, I added my default key to SSH Agent:
ssh-add ~/.ssh/id_rsa
Then, problem solved :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With