Git 推送错误:未找到存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10116373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Push ERROR: Repository not found
提问by Justin
I am having a very strange problem with git
and github
. When I try and push, I am getting:
我对git
and有一个非常奇怪的问题github
。当我尝试推动时,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
I added the remote:
我添加了遥控器:
git remote add origin [email protected]:account-name/repo-name.git
Any ideas?
有任何想法吗?
回答by JT.
Check to see if you have read-write access.
检查您是否具有读写访问权限。
The Git error message is misleading. I had a similar issue. I had been added to an existing project. I cloned it and committed a local change. I went to push and got the ERROR: Repository not found.
error message.
Git 错误消息具有误导性。我有一个类似的问题。我已被添加到现有项目中。我克隆了它并提交了一个本地更改。我去推送并收到ERROR: Repository not found.
错误消息。
The person who added me to the project gave me read-only access to the repository. A change by them and I was able to push.
将我添加到项目的人给了我对存储库的只读访问权限。他们做出了改变,我能够推动。
回答by George Eracleous
I ran into the same issue and I solved it by including my username and password in the repo url:
我遇到了同样的问题,我通过在 repo url 中包含我的用户名和密码来解决它:
git clone https://myusername:[email protected]/path_to/myRepo.git
回答by Emi-C
I had the same problem, with a private repo.
我有同样的问题,有一个私人回购。
do the following:
请执行下列操作:
remove the remote origin
删除远程源
git remote rm origin
re-add the origin but with your username and pwd with writing privileges on this pvt repo
重新添加源,但使用您的用户名和密码,并在此 pvt 存储库上具有写入权限
git remote add origin https://USERNAME:[email protected]/username/reponame.git
回答by Alex Aguilar
I was getting the same error
我遇到了同样的错误
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
and I had created the repository on Github and cloned it locally.
我在 Github 上创建了存储库并将其克隆到本地。
I was able to solve by opening .git/config and removing the [remote "origin"]
section.
我能够通过打开 .git/config 并删除该[remote "origin"]
部分来解决。
[remote "origin"]
url = [email protected]:alexagui/my_project.git
fetch = +refs/heads/*:refs/remotes/origin/*
then I ran the following (again)
然后我运行了以下(再次)
git remote add origin [email protected]:alexagui/my_project.git
git push -u origin master
and this time I was able to push to the repository.
这次我能够推送到存储库。
回答by SandroMarques
回答by Matteo Alessani
I got this error (but before was working). My problem was the missing ssh key binded with the Github account. You can check you current ssh keys with ssh-add -l
.
我收到此错误(但在工作之前)。我的问题是缺少与 Github 帐户绑定的 ssh 密钥。您可以使用ssh-add -l
.
If your key is missing, you can add it with
如果您的密钥丢失,您可以添加它
ssh-add ~/.ssh/your_key
回答by Nikola
I had a similar problem. The incorrect credentials were cached in OS X's key-chain.
我有一个类似的问题。错误的凭据缓存在 OS X 的钥匙串中。
Check out: https://help.github.com/articles/updating-credentials-from-the-osx-keychain
查看:https: //help.github.com/articles/updating-credentials-from-the-osx-keychain
回答by Kirill Evgenevich
git remote rm origin
git remote add origin <remote url>
回答by Gal Shahar
I'm using Macand I struggled to find the solution. My remote address was right and as said, it was a credentials problem. Apparently, in the past I used another Git Account on my computer and the mac's Keychain remembered the credentials of the previous account, so I really wasn't authorised to push.
我正在使用 Mac,我很难找到解决方案。我的远程地址是正确的,如上所述,这是一个凭据问题。显然,过去我在我的电脑上使用了另一个 Git 帐户,Mac 的钥匙串记住了以前帐户的凭据,所以我真的没有被授权推送。
How to fix? Open Keychain Accesson your mac, choose "All Items" category and search for git. Deleteall results found.
怎么修?在 Mac 上打开Keychain Access,选择“所有项目”类别并搜索 git。 删除所有找到的结果。
Now go to the terminal and try to push again. The terminal will ask for username and password. Enter the new relevant credentials and that's it!
现在转到终端并尝试再次推送。终端会要求输入用户名和密码。输入新的相关凭据,就是这样!
Hope it'll help someone. I struggled it for few hours.
希望它会帮助某人。我挣扎了几个小时。
回答by Johnsyweb
remote: Repository not found.
can be a frustratingly misleading error message from githubwhen trying to push to an HTTPS remote where you don't have write permissions.
remote: Repository not found.
尝试推送到您没有写入权限的 HTTPS 远程时,可能是来自github的令人沮丧的误导性错误消息。
Check your write permissions on the repository!
检查您对存储库的写入权限!
Trying an SSH remote to the same repository shows a different response:
尝试使用 SSH 远程访问同一存储库会显示不同的响应:
% git remote add ssh [email protected]: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.
"The correct access rights?"
“正确的访问权限?”
Well why didn't you say so?
那你为什么不说呢?
It's worth noting at this point that while the SSH failure mode in this scenario is slightlybetter, I use HTTPS remotes over SSH because GitHub recommendHTTPS over SSH.
在这一点上值得注意的是,虽然这种情况下的 SSH 故障模式稍微好一些,但我使用 HTTPS 远程服务器而不是 SSH,因为 GitHub推荐HTTPS over SSH。
I understand that GitHub uses "Not Found" where it means "Forbidden" in some circumstances to prevent inadvertently reveling the existence of a private repository.
我知道 GitHub 在某些情况下使用“未找到”表示“禁止”,以防止无意中发现私有存储库的存在。
Requests that require authentication will return
404 Not Found
, instead of403 Forbidden
, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.
在某些地方,需要身份验证的请求将返回
404 Not Found
,而不是403 Forbidden
。这是为了防止私有存储库意外泄露给未经授权的用户。
--GitHub
-- GitHub
This is a fairly common practice around the web, indeed it is defined:
这是网络上相当普遍的做法,确实是这样定义的:
The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
404 (Not Found) 状态码表示源服务器没有找到目标资源的当前表示或不愿意透露一个存在。
--6.5.4. 404 Not Found, RFC 7231 HTTP/1.1 Semantics and Content(emphasis mine)
-- 6.5.4. 404 Not Found,RFC 7231 HTTP/1.1 语义和内容(强调我的)
What makes no sense to me is when I am authenticated with GitHub using a credential helperandI have access to that repository (having successfully cloned and fetched it) that GitHub would chooseto hide its existence from me because of missing write permissions.
对我来说毫无意义的是,当我使用凭证帮助程序通过 GitHub 进行身份验证 并且我有权访问该存储库(已成功克隆并获取它)时,GitHub 会因为缺少写入权限而选择向我隐藏它的存在。
Checking https://github.com/our-organisation/some-repository/using a web browser confirmed that I didn't have write permissions to the repository. Our team's GitHub administrators were able to grant my team write access in a short time and I was able to push the branch up.
使用 Web 浏览器检查https://github.com/our-organisation/some-repository/确认我没有对存储库的写入权限。我们团队的 GitHub 管理员能够在很短的时间内授予我的团队写入权限,并且我能够推动分支。