我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
当前回答
如果您包括您的用户名和回购名称,我们可以合理地帮助您,目前我们没有理由认为回购确实存在。
此外,如果回购是私有的,并且您无法访问它,github将返回“不存在”,以避免披露私有回购的存在。
编辑:如果你不能克隆它,因为它说它不存在,它是私有的,这是因为你没有发送身份验证。确保您的公钥已添加到密匙环,或暂时使用HTTP基本身份验证。
其他回答
如果你的repo之前工作正常,突然弹出这个错误,最有可能的原因是你的git被认证为其他用户,没有访问存储库的权限。因此,为了进行推送,您所需要做的就是在git命令中指定正确的用户名和密码。所以,一个github回购的推命令看起来像:
git push https://youruser:password@github.com/user/reponame.git
用户名和密码需要进行url转义,因此@应该被%40取代,等等。
如果你在Windows上使用Git,试着清除你的凭证:
找到“凭据管理器”(应该在控制面板中) 删除所有与GitHub相关的凭证
都经历过同样的问题。几年来一切都很正常,然后突然出现了这个错误。
问题是,我在用户的github SSH密钥(我总是用来访问有问题的回购)之前向我的SSH代理添加了另一个回购的部署密钥。SSH代理首先尝试了另一个回购的部署键,而GitHub出于一些完全无法解释的原因说
ERROR: Repository not found.
一旦我从SSH代理中删除了部署键,一切就恢复正常了。
remote:未找到存储库。可能是一个令人沮丧的误导错误消息从github试图推到HTTPS远程,你没有写权限。
检查您对存储库的写权限!
尝试SSH远程到相同的存储库显示不同的响应:
% git remote add ssh git@github.com:our-organisation/some-repository.git
% git fetch ssh
From github.com:our-organisation/some-repository
* [new branch] MO_Adding_ECS_configs -> ssh/MO_Adding_ECS_configs
* [new branch] update_gems -> ssh/update_gems
% git push ssh
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
“正确的访问权限?”
那你为什么不早说?
此时值得注意的是,虽然SSH失败模式在此场景中 稍微好一点,我使用HTTPS远程超过SSH,因为 GitHub推荐HTTPS over SSH。
我知道GitHub使用“未找到”的意思是“禁止”在一些 环境防止不经意间泄露了一个私人的存在 存储库。
需要身份验证的请求将返回404 Not Found,而不是 在某些地方是禁止的。这是为了防止意外泄漏 未授权用户的私有存储库。
——GitHub
这在网络上是一种相当普遍的做法,实际上它是这样定义的:
404(未找到)状态代码表示未找到原始服务器 目标资源的当前表示形式或不愿意 揭露它的存在。
——6.5.4。404未找到,RFC 7231 HTTP/1.1语义和内容(重点挖掘)
对我来说毫无意义的是,当我使用一个GitHub认证 凭据助手 并且我可以访问该存储库(已经成功地克隆和获取 它),GitHub会选择隐藏它的存在对我因为失踪 写权限。
通过网络查看https://github.com/our-organisation/some-repository/ 浏览器确认我没有写存储库的权限。我们的 团队的GitHub管理员能够在短时间内授予我的团队写访问权 好不容易,我终于把树枝推了上去。
Normally it happens because the project is private and you have not rights to write it. I had the same "problem" a few times, and it was for that reason. If the project it is yours, just create a private and a public key following this link: https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and add them to the "SSH and Key" section on gitHub, then you will be able to push to the repo. In the other hand if the project it is not your, ask the owner to give you the rights for it.