Git认为我是错误的用户 [英] Git thinks I'm the wrong user
问题描述
我在Mac OSX上,git版本 1.8.5.2(Apple Git-48)
I am on Mac OSX, git version 1.8.5.2 (Apple Git-48)
一个git repo中的git子模块,据我所知,它只能被一个git用户和rsa密钥克隆,拉取,提交,合并和推送。我有许多其他的用户和密钥对,但在〜/ .gitconfig文件中没有指定其他用户。
I had a git submodule in a git repo that had (to my knowledge) only ever been cloned, pulled, committed, merged and pushed using one git user and rsa key. I have many other pairs of users and keys but no others were specified in the ~/.gitconfig file.
当这个子模块的远程 https:// github
...等等。它允许我提交正确的用户名和电子邮件,但推送时会告诉我:
When this submodule had the remote of https://github
... etc. It would allow me to commit with the correct username and email being applied but when pushing, would tell me that:
remote: Permission to some_username/project.git denied to user2.
fatal: unable to access 'https://github.com/some_username/project.git/': The requested URL returned error: 403
但是,当我删除 https:// ...
remote时,使用了 git @ github.com:some_username/project.git
remote,它工作正常。
However when I removed the https://...
remote and instead used the git@github.com:some_username/project.git
remote, it works correctly.
这是git或github的错误吗?有没有其他方法可以解决这个问题?这两个用户在其github账户中都有关联的rsa密钥。
Is this a bug with git or github? Was there any other way to fix it? Both these users have their associated rsa keys associated on their github accounts.
推荐答案
使用git或github?
Is this a bug with git or github?
不:使用https url,您需要在url中添加登录名,以便了解git的凭据请求:
No: with https url, you need to add the login in the url for git to know what credential to ask for:
cd /path/to /your/submodule
git remote set-url origin https://yourLogin@github.com/yourLogin/yourRepo
ssh url会自动使用您的密钥(在 $ HOME / .ssh / id_rsa.pub
)其中,如果发布到你的账户(如果你的账户是GitHub仓库的所有者或合作者)
An ssh url would use automatically your key (in $HOME/.ssh/id_rsa.pub
) which, if published to your account (and if your account is the owner or collaborator of the GitHub repo)
这篇关于Git认为我是错误的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!