github我是谁?(OSX)

Yus*_*f X 6 git macos github

我想我是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
Run Code Online (Sandbox Code Playgroud)

然后,我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.
Run Code Online (Sandbox Code Playgroud)

然后我改变了一些东西,提交并推送:

$ 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
Run Code Online (Sandbox Code Playgroud)

是Github关于这个错误的唯一说法.

为什么git/github认为我在推动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.
Run Code Online (Sandbox Code Playgroud)

我没有〜/ .ssh/config或/ etc/ssh/ssh_config文件.我在Mac FWIW上.

Yus*_*f X 5

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


Roo*_*ahi 5

我有同样的问题。我能够使用以下命令找出 git 使用的密钥:

ssh -v -T git@github.com
Run Code Online (Sandbox Code Playgroud)

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

ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

然后,问题解决了:-)