Macos 我是谁?(OSX)
我认为我是github用户A,但github认为我是用户B。首先,我检查我是谁:Macos 我是谁?(OSX),macos,git,github,Macos,Git,Github,我认为我是github用户A,但github认为我是用户B。首先,我检查我是谁: $ git config --list color.ui=auto push.default=simple user.name=USER_A user.email=USER_A@gmail.com core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true core.ignorecase=t
$ git config --list
color.ui=auto
push.default=simple
user.name=USER_A
user.email=USER_A@gmail.com
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
然后,我将克隆我的回购:
$ 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.
然后我更改某些内容,提交并推送:
$ 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
Github关于这个错误的唯一说法是
编辑:根据评论,我运行了以下测试:
$ ssh -T git@github.com
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.
我没有~/.ssh/config或/etc/ssh/ssh\u配置文件。我在Mac FWIW上。我发现了问题,我的Mac钥匙链有用户B。我在钥匙链应用程序中搜索“github”时找到了它。我已经更新了问题,以反映这是Mac特有的问题/解决方案。我也遇到了同样的问题。我可以使用以下命令找到git使用的密钥:
ssh -v -T git@github.com
然后,我看到github正在使用另一个键;因此,我将默认密钥添加到SSH代理:
ssh-add ~/.ssh/id_rsa
然后,问题解决了:-)如果您遇到问题,我会做以下几件事: 跑 说明:当您第一次配置git时,通常会在设置阶段完成很多事情。其中之一是配置您是谁以及您使用的电子邮件地址。如果您检查上述命令的以下输出。您将看到正在使用的user.name
user.name = BlahBlah Name
user.email = blahadklhf@gmail.com
导致此问题的可能不是
git
,而是您的ssh
连接。您在那里使用的用户名是什么?ssh-Tgit@github.com
查看您正在使用哪个用户访问github。如果它是USER_B,那么请检查您的ssh配置。谢谢,我运行了它(请参阅问题底部的编辑),它认为我是USER_A。听起来您想使用ssh,而不是https。尝试重新克隆,但请确保使用ssh
url。(应该是:git@github.com:username/reponame.git
)。您可能缓存了不正确的https凭据,请参阅:user.name
和user.email
中列出的git config
仅用于提交,不用于网络身份验证。最初问题中的第一条命令是这样说的。
user.name = BlahBlah Name
user.email = blahadklhf@gmail.com