git-update-server-info不足以克隆远程仓库?

时间:2010-09-08 12:51:56

标签: git http clone

我想通过Nginx HTTPS服务器创建一个git存储库。

我设置了post-commit钩子来运行git-update-server-info以更新“dumb”后端的refs。

通过HTTPS接口提取更新工作正常,但是,在最初检出存储库时,它失败了:

[test@test ttt]$ git clone https://server/git/test.git/
Cloning into thesis...
Username: 
Password: 
error: The requested URL returned error: 401 (curl_result = 22, http_code = 401, sha1 = 2be2bcc15d1a79eb4e37e03fd2070ee0f229457c)
error: Unable to find 2be2bcc15d1a79eb4e37e03fd2070ee0f229457c under https://test/git/test.git
Cannot obtain needed commit 2be2bcc15d1a79eb4e37e03fd2070ee0f229457c
while processing commit 6c155f7098fd75f23edf71ac5b70b7c22f6070e7.
error: Fetch failed.

在服务器端存储库上手动运行“git update-server-info”无法解决问题,但运行“git gc”会解决问题。

但是,“git gc”修复只有在我将更新推送到服务器之后才会有效,之后整个“git clone”问题再次启动。

在服务器上我正在运行git 1.7.1(来自Debian backports),在客户端我正在运行1.7.2.2(来自Arch Linux)

有关如何解决此问题的任何提示?不幸的是,运行“智能”HTTP后端目前不是一种选择。

3 个答案:

答案 0 :(得分:10)

有相同的错误,但包含URL中的用户名对我有用:

https://myuser@server/git/test.git/

答案 1 :(得分:4)

我在这里遇到同样的问题,这对我来说似乎是一个错误:虽然git要求输入用户名和密码,但它不会将其传递给服务器,因此服务器正确响应401(未授权)。

到目前为止我找到的解决方案:正确设置我的netrc。简单地说

machine <server>
login <username>
password <password>
在$ HOME / .netrc中的

或msysgit的$ HOME / _netrc,验证将正常完成。

答案 2 :(得分:1)