(一些重要的背景):我是我的作品的 github 存储库的所有者。对于这个例子,我将其称为“组织/组织”
因此,我创建了一些个人的副项目代码,然后决定将其推送到新的存储库。我在 github.com 创建了一个新的存储库。然后做了:
git init
git add -A
git commit -am "first commit"
git remote add origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7b0bea397b0bea3bfa2b5f9b4b8ba" rel="noreferrer noopener nofollow">[email protected]</a>:fakename/testapp.git
git push -u origin master
一切正常,直到最后一个命令:
git push -u origin master
然后我收到此错误:
ERROR: Permission to fakename/testapp.git denied to organization/organization.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
为什么 git 认为我是一个组织?!?!这是我的配置:
user.name=Mad Jon
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572224322579323a363e3b6a273225243839363b323a363e3b173f38233a363e3b7934383a" rel="noreferrer noopener nofollow">[email protected]</a>
core.ignorecase=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c3b1a6aeacb7a6edacb1aaa4aaadedb6b1affea4aab783a4aab7abb6a1eda0acae" rel="noreferrer noopener nofollow">[email protected]</a>:fakename/testapp.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
我没有做任何与我的组织有关的事情。我不知道为什么它认为我就是它。但我希望它强制它认为我是普通用户。不是组织。
最佳答案
当使用 ssh url(如 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66010f1226010f120e13044805090b" rel="noreferrer noopener nofollow">[email protected]</a>:fakename/testapp.git
)时,最可能的解释是您没有定义新的 ssh key ,而是使用了适当的 ~/.ssh/config
file以便向 Git 声明要使用的 ssh key 。
您的 ssh 网址将变为:
mysecondrepo:fakename/testapp.git
使用 ssh 配置文件,例如:
Host mysecondrepo
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_mysecondrepo
有关多个 ssh key 管理的更多信息,请参阅“How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account? ”。
当然,切换到 https url(如 commented by the OP )可以:
https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5731363c3239363a3217303e233f22357934383a" rel="noreferrer noopener nofollow">[email protected]</a>/fakename/testapp.git
它强制您识别您的帐户。
但它并没有解决 ssh 配置问题。
关于git - 尝试创建一个新的存储库,但 git 认为我是一个组织,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21085441/