`git clone` over"dumb"http协议失败,找不到'repository'

man*_*ake 7 git

我的问题

我正在尝试使用dumb http协议在我们公司的Intranet服务器上共享一个git repo ,它只需要文件访问,但它失败了

fatal: repository 'http://my-url/repo.git' not found
Run Code Online (Sandbox Code Playgroud)

但是,粘贴在Firefox相同的链接给我的指标到裸露的回购有branches/,config,description,HEAD等所有的目录和文件读取.事实上,如果我使用wget递归地下载整个事物,我可以git clone在本地下载,所以所有必需的文件似乎都可以访问而没有问题.

$ wget -r --no-parent --reject "index.html*" http://my-url/repo.git
$ git clone repo.git test
Cloning into 'test'...
done.
Run Code Online (Sandbox Code Playgroud)

继续调试我尝试使用GIT_CURL_VERBOSE和详细输出GIT_TRACE:

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone http://my-url/repo.git test
trace: built-in: git 'clone' 'http://my-url/repo.git' 'test'
Cloning into 'test'...
trace: run_command: 'git-remote-http' 'origin' 'http://my-url/repo.git'
* Couldn't find host my-url in the .netrc file; using defaults
* About to connect() to my-url port 80 (#0)
*   Trying <ip>...
* Connected to my-url (<ip>) port 80 (#0)
> GET /repo.git/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/1.8.3.1
Host: my-url
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

< HTTP/1.1 404 Not Found
< Date: Fri, 04 Sep 2015 13:41:56 GMT
< Server: Apache/2.2.15 (Red hat)
< shortcut-icon: /images/logo.ico
< Content-Length: 346
< Content-Type: text/html; charset=iso-8859-1
< X-Cache: MISS from my-url
< 
* Connection #0 to host my-url left intact
fatal: repository 'http://my-host/repo.git/' not found
Run Code Online (Sandbox Code Playgroud)

对我来说,看起来它在尝试"智能"http协议后放弃了.发生什么了?从我能够收集到的愚蠢的http协议还没有被删除.为什么git在尝试智能http后会放弃?

细节

  • HTTP Server是Apache 2.2.15
  • 允许通过HTTP进行匿名读取访问
  • git版本1.8.3.1
  • 回购是裸的,没有符号链接
  • git update-server-info 已手动调用.
  • 我无权访问服务器而无法对其进行配置,因此"智能http"选项已经用完.
  • 任何(全局,系统,本地)git-config中唯一的东西是user.nameuser.email.
  • env | grep GIT 是空的
  • 结果是相同的https.

编辑: 更新了https的结果(相同)


类似的问题

类似的问题,但没有在这种情况下有用的答案: Git Clone - 未找到存储库

也类似,但接受的答案使用"智能http"协议. git cloneover HTTP失败,找不到"存储库"

Joh*_*ill 8

看来你必须运行:

git update-server-info
Run Code Online (Sandbox Code Playgroud)

在 repo 可以通过 http 提供服务之前。

您还需要打开 post-update 挂钩:

mv hooks/post-update.sample hooks/post-update
Run Code Online (Sandbox Code Playgroud)

每当将新更改推送到存储库时,它都会重新运行git update-server-info

有关更多信息,请参阅此处的“Dumb http”部分:

https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols


man*_*ake 6

TL;DR:手动提供禁用“智能”http 协议的选项:

$ GIT_SMART_HTTP=0 git clone http://my-dumb-http-server/repo.git
Run Code Online (Sandbox Code Playgroud)

但根据 https://git-scm.com/book/ch4-1.html

如果服务器没有响应 Git HTTP 智能服务,Git 客户端将尝试回退到更简单的“哑”HTTP 协议。

出于某种原因,情况似乎并非如此。但是在深入研究代码后,我看到他们检查了GIT_SMART_HTTP环境变量,我git clone通过设置GIT_SMART_HTTP=0.