Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push over HTTP (not HTTPS) on Ubuntu hangs after sending files

I have seen lots of instances of similar problems, but they usually seem to relate to HTTPS (as shown below, I'm using straight HTTP) or buffer size (I've tried setting the buffer size up using "git config http.postBuffer 524288000" even though the file I'm pushing is empty) or using Windows on the client side (I'm on Ubuntu).

I have set up a git server using git-http-backend, created an empty repo on the server, and cloned it successfully locally. I added one empty file and am attempting to push it, and it uploads then hangs after the total line.

$ 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:[email protected]/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:[email protected]/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:[email protected]/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:[email protected]/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:[email protected]/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

In the server apache error log, I see this line at this point:

[Sat Sep 10 08:07:46 2016] [error] [client 204.15.222.20] fatal: The remote end hung up unexpectedly
like image 538
Jon Vance Avatar asked Sep 10 '16 14:09

Jon Vance


People also ask

Why is my git push not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

How do you fix a remote end hung up unexpectedly?

Solution. To solve the issue, change the settings of your buffer so that you have enough space available. You can increase the buffer value up to 2000000000.

What is http postBuffer?

postBuffer is about: Maximum size in bytes of the buffer used by smart HTTP transports when POSTing data to the remote system.

What is git buffer size?

The default is 1MB.


1 Answers

First, at least set git config --global push.default simple: that will avoid the noise you see when pushing.

Second, make sure to use Git 2.10 for both the client and the server.
That will allow for more trace options, like the recent GIT_TRACE_CURL.

Third, for testing, try and deactivate authentication on the Apache side to see if the push completes then (there was an issue before, in "git refuses to send credentials over http?")


Note that iwth Git 2.17 (Q2 2018), the http tracing code, often used to debug connection issues, learned to redact potentially sensitive information from its output so that it can be more safely sharable.

See commit 8ba18e6, commit 8341178 (19 Jan 2018) by Jonathan Tan (jhowtan).
(Merged by Junio C Hamano -- gitster -- in commit 5327463, 13 Feb 2018)

http: support omitting data from traces

GIT_TRACE_CURL provides a way to debug what is being sent and received over HTTP, with automatic redaction of sensitive information.
But it also logs data transmissions, which significantly increases the log file size, sometimes unnecessarily.

Add an option "GIT_TRACE_CURL_NO_DATA" to allow the user to omit such data transmissions.

like image 171
VonC Avatar answered Oct 16 '22 18:10

VonC