发送文件后,Uitntu上的Git push over HTTP(不是HTTPS)挂起

时间:2016-09-10 14:25:27

标签: git apache http ubuntu

我已经看到很多类似问题的实例,但它们通常似乎与HTTPS(如下所示,我使用的是直接HTTP)或缓冲区大小有关(我尝试使用“git config设置缓冲区大小) http.postBuffer 524288000“即使我推送的文件是空的”或在客户端使用Windows(我在Ubuntu上)。

我已经使用git-http-backend设置了一个git服务器,在服务器上创建了一个空的repo,并在本地成功克隆了它。我添加了一个空文件并试图推送它,然后上传然后挂起总线。

$ GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push
07:07:45.884509 git.c:344               trace: built-in: git 'push'
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

07:07:45.886216 run-command.c:334       trace: run_command: 'git-remote-http' 'origin' 'http://user:password@server.com/git/tmp.git'
* Couldn't find host server.com in the .netrc file; using defaults
*   Trying 74.220.207.144...
* Connected to server.com (74.220.207.144) port 80 (#0)
> GET /git/tmp.git/info/refs?service=git-receive-pack HTTP/1.1
Host: server.com
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: text/html
< Content-Length: 134
< Connection: keep-alive
< WWW-Authenticate: Basic realm="Git Repo"
< Accept-Ranges: bytes
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Ignoring the response-body
* Connection #0 to host server.com left intact
* Issue another request to this URL: 'http://user:password@server.com/git/tmp.git/info/refs?service=git-receive-pack'
* Couldn't find host server.com in the .netrc file; using defaults
* Found bundle for host server.com: 0xedc7c0 [can pipeline]
* Re-using existing connection! (#0) with host server.com
* Connected to server.com (74.220.207.144) port 80 (#0)
* Server auth using Basic with user 'user'
> GET /git/tmp.git/info/refs?service=git-receive-pack HTTP/1.1
Host: server.com
Authorization: Basic anASDCNakvca0941cas65w==
User-Agent: git/2.7.4
Accept: */*
Accept-Encoding: gzip
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 200 OK
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: application/x-git-receive-pack-advertisement
< Content-Length: 127
< Connection: keep-alive
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Connection #0 to host server.com left intact
07:07:46.424994 run-command.c:334       trace: run_command: 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.425961 exec_cmd.c:120          trace: exec: 'git' 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.435357 git.c:344               trace: built-in: git 'send-pack' '--stateless-rpc' '--helper-status' '--thin' '--progress' 'http://user:password@server.com/git/tmp.git/' '--stdin'
07:07:46.436162 run-command.c:334       trace: run_command: 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
07:07:46.436700 exec_cmd.c:120          trace: exec: 'git' 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
07:07:46.439015 git.c:344               trace: built-in: git 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
Counting objects: 3, done.
Writing objects: 100% (3/3), 200 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
* Couldn't find host server.com in the .netrc file; using defaults
* Found bundle for host server.com: 0xedc7c0 [can pipeline]
* Re-using existing connection! (#0) with host server.com
* Connected to server.com (74.220.207.144) port 80 (#0)
* Server auth using Basic with user 'user'
> POST /git/tmp.git/git-receive-pack HTTP/1.1
Host: server.com
Authorization: Basic anASDCNakvca0941cas65w==
User-Agent: git/2.7.4
Accept-Encoding: gzip
Content-Type: application/x-git-receive-pack-request
Accept: application/x-git-receive-pack-result
Content-Length: 336

* upload completely sent off: 336 out of 336 bytes
< HTTP/1.1 200 OK
< Server: nginx/1.10.1
< Date: Sat, 10 Sep 2016 14:07:46 GMT
< Content-Type: application/x-git-receive-pack-result
< Content-Length: 21
< Connection: keep-alive
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
< Content-Encoding: gzip
< 
* Connection #0 to host server.com left intact

在服务器apache错误日志中,我此时看到此行:

[Sat Sep 10 08:07:46 2016] [error] [client 204.15.222.20] fatal: The remote end hung up unexpectedly

1 个答案:

答案 0 :(得分:2)

首先,至少设置git config --global push.default simple:这样可以避免推动时看到的噪音。

其次,确保为客户端和服务器使用Git 2.10 这将允许更多跟踪选项,例如最近的GIT_TRACE_CURL

第三,对于测试,尝试并停用Apache端的身份验证以查看推送是否完成(之前出现问题,在“git refuses to send credentials over http?”中)

请注意,iwth Git 2.17(2018年第二季度),http跟踪代码,通常用于调试连接问题,学习如何从其输出中编辑潜在的敏感信息,以便更安全地共享。

commit 8ba18e6commit 8341178Jonathan Tan (jhowtan)(2018年1月19日) (由Junio C Hamano -- gitster --合并于commit 5327463,2018年2月13日)

  

http:支持忽略跟踪数据

     

GIT_TRACE_CURL提供了一种调试发送和接收内容的方法   通过HTTP,自动编辑敏感信息。
  但它也会记录数据传输,这会显着增加日志文件   大小,有时不必要。

     

添加选项“GIT_TRACE_CURL_NO_DATA”以允许用户省略此类数据传输。