簡體   English   中英

`git clone` over“dumb”http協議失敗,找不到'repository'

[英]`git clone` over “dumb” http protocol fails with `repository not found`

我的問題

我正在嘗試使用dumb http協議在我們公司的Intranet服務器上共享一個git repo,它只需要文件訪問,但它失敗了

fatal: repository 'http://my-url/repo.git' not found

但是在Firefox中粘貼相同的鏈接會給我帶有branches/configdescriptionHEAD等的倉庫的索引。所有目錄和文件都是可讀的。 事實上,如果我使用wget以遞歸方式下載整個內容,我可以從中進行本地git clone ,因此所有必需的文件似乎都可以無問題地訪問。

$ wget -r --no-parent --reject "index.html*" http://my-url/repo.git
$ git clone repo.git test
Cloning into 'test'...
done.

繼續調試我嘗試使用GIT_CURL_VERBOSEGIT_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

對我來說,看起來它在嘗試“智能”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 env | grep GIT是空的
  • https的結果相同。

編輯:更新了https的結果(相同)


類似的問題

類似的問題,但沒有在這種情況下有用的答案: Git Clone - 未找到存儲庫

也類似,但接受的答案使用“智能http”協議。 HTTP上的git clone失敗,“找不到存儲庫”

看來你必須運行:

git update-server-info

在通過http提供回購之前。

您還需要打開更新后的掛鈎:

mv hooks/post-update.sample hooks/post-update

每當新的更改被推送到repo時,這將重新運行git update-server-info

有關詳細信息,請參閱此處“Dumb http”部分:

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

TL; DR:手動提供禁用“智能”http協議的選項:

$ GIT_SMART_HTTP=0 git clone http://my-dumb-http-server/repo.git

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

如果服務器沒有響應Git HTTP智能服務,Git客戶端將嘗試回退到更簡單的“啞”HTTP協議。

出於某種原因,似乎並非如此。 但是在挖掘代碼之后,我看到他們檢查了GIT_SMART_HTTP環境變量,並通過設置GIT_SMART_HTTP=0來使git clone工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM