github我是谁? (OSX)

时间:2015-04-12 22:06:03

标签: macos git github

我想我是 USER_A ,但github认为我 USER_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=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克隆我的回购:

$ 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

This Github唯一能说出这个错误。

Why does git/github think I'm pushing as USER_B?!

编辑:根据评论,我运行了这个测试:

$ 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_config文件。我是Mac FWIW。

3 个答案:

答案 0 :(得分:5)

我发现了问题,我的Mac钥匙串有USER_B。当我搜索" github"在钥匙串应用程序中。我已经更新了问题,以反映这是特定于Mac的问题/解决方案。

答案 1 :(得分:4)

我遇到了同样的问题。我能够使用以下命令找出git使用了哪个键:

ssh -v -T git@github.com

然后,我看到github正在使用另一个密钥;所以,我将我的默认密钥添加到SSH代理:

ssh-add ~/.ssh/id_rsa

然后,问题解决了: - )

答案 2 :(得分:-1)

如果您遇到麻烦,我会做几件事:

运行

Vics-iMac:ansible vic$ git config --list

说明:通常在首次配置git时,在设置阶段会做很多事情。其中之一是配置您的身份以及您使用的电子邮件地址。如果您从上面的命令检查以下输出。您将看到正在使用的用户名。

user.name = BlahBlah Name
user.email = blahadklhf@gmail.com