git - 为什么我刚克隆 GitHub 时会说“找不到存储库”?
问题描述
尝试对 GitHub 私有托管的 Git 存储库进行简单更改。我克隆了存储库,进行了更改,然后将其推送以供审核。git push
没有成功,我想也许我在克隆存储库时对远程 URL 进行了粗暴的处理(但这不可能是正确的,因为我已经成功克隆了存储库,对吧?)。我尝试删除并重新添加遥控器,但推送仍然失败:
为了说明问题:
% git remote -v
origin https://github.com/our-organisation/some-repository.git (fetch)
origin https://github.com/our-organisation/some-repository.git (push)
% git fetch -v origin
From https://github.com/our-organisation/some-repository
= [up to date] MO_Adding_ECS_configs -> origin/MO_Adding_ECS_configs
= [up to date] update_gems -> origin/update_gems
% git push -v origin
Pushing to https://github.com/our-organisation/some-repository.git
remote: Repository not found.
fatal: repository 'https://github.com/our-organisation/some-repository.git/' not found
[某些名称可能已更改。]
当远程 URL 正确时,为什么 GitHub 会说“找不到存储库”?
解决方案
检查您对存储库的写入权限!
我的一些同事很有帮助地建议我尝试使用 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
,而不是 。403 Forbidden
这是为了防止私有存储库意外泄漏给未经授权的用户。
-- GitHub
对我来说没有意义的是,当我使用 凭证助手通过 GitHub 进行身份验证 并且我可以访问该存储库(已成功克隆并获取它)时,GitHub 会因为缺少写权限而选择对我隐藏它的存在。
使用网络浏览器检查https://github.com/our-organisation/some-repository/确认我没有对存储库的写入权限。我们团队的 GitHub 管理员能够在短时间内授予我的团队写入权限,并且我能够将分支向上推。
希望这个问答对未来的人们有所帮助。
推荐阅读
- java - 如何在android studio中重新打开应用程序后打开最近的活动
- python - 在 yapfignore 中包含的文件上预提交 yapf 失败
- r - ENMeval 教程后的 sf_buffer 结果不正确
- amazon-web-services - 无法在 AWS 上编辑权限 JSON,尽管它告诉我我可以
- cartopy - 无法使用 cartopy 显示经纬度和海岸线
- django - 将主页和关于页面添加到 Django 动态 sitemap.xml
- python - 如果它在字符串中并导致错误,则返回错误消息 - Python 3
- php - 在 Laravel 8 中使用 $errors 变量包含额外的验证
- java - Maven - 从多模型项目中构建几个模块
- shell - 为 Redis 实例定制的 liveness probe