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

Jon*_*nce 10 apache git ubuntu http

我见过很多类似问题的实例,但它们通常似乎与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
Run Code Online (Sandbox Code Playgroud)

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

[Sat Sep 10 08:07:46 2016] [error] [client 204.15.222.20] fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 2

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

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

第三,为了测试,尝试在 Apache 端停用身份验证,看看推送是否完成(之前有一个问题,在“ git 拒绝通过 http 发送凭据? ”)


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

请参阅Jonathan Tan ( )提交的提交 8ba18e6提交 8341178(2018 年 1 月 19 日)。(由Junio C Hamano 合并 -- --提交 5327463中,2018 年 2 月 13 日)jhowtan
gitster

http:支持从迹线中省略数据

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

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