Git 致命错误:找不到信息/参考
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12406963/
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 Fatal Error: info/refs not found
提问by B6431
I receive the following error:
我收到以下错误:
fatal: https://github.com/username/repository-name.git/info/refs not found: did you run git update-server-info on the server?
if I try to push my repository without creating it first on github.com. If I create my repository first on github, then I can push branches no problem. Is this procedure routine? Or am I doing something wrong? I thought a repository could be created locally and pushed without first creating it on github.
如果我尝试推送我的存储库而不先在 github.com 上创建它。如果我首先在 github 上创建我的存储库,那么我可以毫无问题地推送分支。这个程序是例行公事吗?还是我做错了什么?我认为可以在本地创建存储库并推送,而无需先在 github 上创建它。
回答by nulltoken
fatal: https://github.com/username/repository-name.git/info/refsnot found: did you run git update-server-info on the server?
致命:https: //github.com/username/repository-name.git/info/refs未找到:您是否在服务器上运行了 git update-server-info?
In GitHub context, this message should be understood as "The repository doesn't exist". You're supposed to push toward an already existing bare repository. A bare repository is a repository without a working directory, usually found server-side.
在 GitHub 上下文中,此消息应理解为“存储库不存在”。您应该推动已经存在的裸存储库。裸仓库是没有工作目录的仓库,通常在服务器端找到。
If I create my repository first on github, then I can push branches no problem. Is this procedure routine?
如果我首先在 github 上创建我的存储库,那么我可以毫无问题地推送分支。这个程序是例行公事吗?
Yes. You're supposed to first create your repository on GitHub. See the help topic about this
是的。您应该首先在 GitHub 上创建您的存储库。请参阅有关此的帮助主题
indeed, as stated by the documentation "To put your project up on GitHub, you'll need to have a GitHub repository for it to live in."
事实上,正如文档中所说的“要将您的项目放在 GitHub 上,您需要有一个 GitHub 存储库才能让它存在。”
回答by VonC
I confirm you need to create your repo on GitHub first, before being able to push to said (remote) repo.
我确认您需要先在 GitHub 上创建您的存储库,然后才能推送到所述(远程)存储库。
Once created, you can add it as a remote named 'origin' to your local repo, and 'git push origin master
' (for the first push).
创建后,您可以将其作为名为 'origin' 的远程添加到本地存储库和 ' git push origin master
'(用于第一次推送)。
回答by kforbesie
Also note that the repository name is case sensitive. Oops!
另请注意,存储库名称区分大小写。哎呀!
回答by l3x
Are you sure the git repo you're trying to access supports the HTTPS protocol?
您确定您尝试访问的 git 存储库支持 HTTPS 协议吗?
Instead of this: git clone https://github.com/TeaCodie/TeaCodie-Website.git
取而代之的是: git clone https://github.com/TeaCodie/TeaCodie-Website.git
Try this: git clone [email protected]/TeaCodie/TeaCodie-Website.git
尝试这个: git clone [email protected]/TeaCodie/TeaCodie-Website.git
You may need to configure your SSH key.
您可能需要配置 SSH 密钥。
For some details, see: http://git-scm.com/book/ch4-1.htmland https://help.github.com/articles/set-up-gitand https://help.github.com/articles/generating-ssh-keys
有关详细信息,请参阅:http ://git-scm.com/book/ch4-1.html和https://help.github.com/articles/set-up-git和https://help.github。 com/articles/generate-ssh-keys
回答by user1369430
The issue I had was due to the fact that the user didn't have write permission on the master branch.
我遇到的问题是由于用户在 master 分支上没有写权限。
回答by mridula
Also, make sure the repository URL is reachable from your network.
此外,请确保可以从您的网络访问存储库 URL。
In my case, my internet subscription was close to expiring so my service provider was redirecting all the HTTP/HTTPS calls to their renewal page.
就我而言,我的互联网订阅即将到期,因此我的服务提供商将所有 HTTP/HTTPS 调用重定向到他们的续订页面。
So, GIT could not reach the repository.
因此,GIT 无法访问存储库。
回答by Dr. Michel C.
I had the same error info/refs not found
when I was cloning a local repository and serving it via http.
info/refs not found
当我克隆本地存储库并通过 http 提供服务时,我遇到了同样的错误。
It seems that cloning a repository doesn't create the info/refs file and therefore it cannot been served remotely (https, ssh etc.) as remotely there is no way to get the name of the master branch without listing the .git folder, so the info/refs provides the path and the commitid for current git repository HEAD .
似乎克隆存储库不会创建 info/refs 文件,因此它无法远程提供(https、ssh 等),因为远程无法在不列出 .git 文件夹的情况下获取主分支的名称,所以 info/refs 提供了当前 git 存储库 HEAD 的路径和 commitid。
mkdir clone-without-refs; cd clone-without-refs
git clone ../origin.git .
ls -l .git/info
so I created it by hand this way (in the source repository, assuming you run a /bin/sh
type of shell)
所以我以这种方式手工创建了它(在源存储库中,假设您运行一种/bin/sh
shell)
gitid=$(git rev-parse HEAD)
echo HEAD: $gitid
echo -e "$gitid\trefs/heads/master" > .git/info/refs
if [ ! -e .git/refs/heads/master ]; then
echo $gitid > .git/refs/heads/master
fi
then I did my cloning again and it worked (change $origin
with yours):
然后我再次进行了克隆并且它起作用了($origin
与您的相同):
rm -rf ../cloned
# checking if refs file is there (httpds server side):
origin="http://localhost:8080/~$USER/$(pwd|sed -e "s,$HOME/,,")/.git"
curl $origin/info/refs
git clone $origin ../cloned
# verify
git -C ../cloned log -2