无法通过 http 克隆 git repos;未找到信息/参考

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19698352/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:17:21  来源:igfitidea点击:

can't clone git repos via http; info/refs not found

githttprepositoryclonegit-bare

提问by epl

I am trying to make a git repository available for read-only access over http.

我正在尝试使 git 存储库可用于通过 http 进行只读访问。

I am doing it the old-style way because git-http-backendis not available on my host system. That is, I am simply putting the bare repository in a http accessible location.

我正在以旧式方式执行此操作,因为git-http-backend在我的主机系统上不可用。也就是说,我只是将裸存储库放在一个 http 可访问的位置。

I created the bare repository successfully on the host using git clone --bare <some-remote-location>.

我使用git clone --bare <some-remote-location>.

Now, when I point git to the new clone using git clone http://my.host.name/location, a message reports repository not found.

现在,当我使用 将 git 指向新的克隆时git clone http://my.host.name/location,一条消息报告repository not found.

When I capture network traffic, I see that git is attempting to access http://my.host.name/location/info/refs. This would be expected to fail because there is no info/refspath in the repository. Rather there are infoand refsdirectories directly beneath the repository root.

当我捕获网络流量时,我看到 git 正在尝试访问http://my.host.name/location/info/refs. 这会失败,因为info/refs存储库中没有路径。而是直接在存储库根目录下有inforefs目录。

Evidently the cloned bare repository is not structured as expected by the client. Does anyone know why this might be?

显然,克隆的裸存储库没有按照客户的预期结构化。有谁知道为什么会这样?

回答by poke

You will need to run git update-server-infoon the server to generate the files necessary for the “dumb protocol” to work.

您需要git update-server-info在服务器上运行以生成“哑协议”工作所需的文件。

回答by u1860929

Try the steps mentioned here on git-scm for http/s protocol.

尝试在 git-scm for http/s protocol 上提到的步骤。

Basically, after doing the git clone --bare <path-to-repository>, you need to run mv hooks/post-update.sample hooks/post-updatewithing your bare repository and then do a git update-server-infoonce and then you should be able to clone the repo.

基本上,在完成之后git clone --bare <path-to-repository>,您需要使用mv hooks/post-update.sample hooks/post-update裸存储库运行,然后执行git update-server-info一次,然后您应该能够克隆存储库。

回答by idej1234

I have had this issue when the remote is running on a git repository 1.7.X and the git client is 1.8.X ; I proved it by downgrading my client to 1.7.X - this fixed the issue. So make sure git is the same version on "client" and "server" sides. The command I was running was git clone .

当远程在 git 存储库 1.7.X 上运行并且 git 客户端是 1.8.X 时,我遇到了这个问题;我通过将我的客户端降级到 1.7.X 来证明这一点——这解决了这个问题。因此,请确保 git 在“客户端”和“服务器”端的版本相同。我运行的命令是 git clone 。

回答by Marcs

Remember also to check that the required modules are enable on apache. These are the required modules for git over HTTP:

还记得检查所需的模块是否在 apache 上启用。这些是 git over HTTP 所需的模块:

  • mod_alias
  • mod_cgi
  • mod_env
  • mod_alias
  • mod_cgi
  • mod_env

回答by qfazille

I had the same error trying to clone a gitlab projectbecause I set a wrong path !
I took the SSHpath instead of the HTTPpath. (+ do not forget the .git)

我在尝试克隆gitlab 项目时遇到了同样的错误,因为我设置了错误的路径!
我选择了SSH路径而不是HTTP路径。(+ 不要忘记.git)

git clone *HTTP_path.git*