Tracking Down GIT Errors

Tracking Down GIT Errors

Recently, I had a problem where a `git push` to a remote repository did not work.

The only output was the following error message:

fatal: git fetch-pack: expected ACK/NAK, got '??                                                                                ?
 *** Server encountered a fatal error handling the push: Protocol got unexpected flush-pkt'

Since this error message could be caused by all sorts of things, it would be useful to get more information.

Fortunately, there are the following environment variables you can set.

export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

After that, you get more information. Here is an excerpt from the detailed log:

08:15:30.458568 pkt-line.c:80           packet:        fetch< ACK b8e20df206a89271c03edf8d3f9dccd096443a78 common
08:15:30.458572 pkt-line.c:80           packet:        fetch< ACK 2a530dc36296314cab72cf189d3f5aafe920a7e9 common
08:15:30.458575 pkt-line.c:80           packet:        fetch< ACK 7dbf365fbab6c6d1d5bee5b0f2225b98a1d44209 common
08:15:30.458579 pkt-line.c:80           packet:        fetch< NAK
08:15:30.500565 pkt-line.c:80           packet:        fetch< ACK 7dbf365fbab6c6d1d5bee5b0f2225b98a1d44209
08:15:30.538730 pkt-line.c:80           packet:     sideband< PACK ...
08:15:30.538826 run-command.c:643       trace: run_command: git --shallow-file  unpack-objects -q --pack_header=2,21
08:15:30.553249 git.c:418               trace: built-in: git unpack-objects -q --pack_header=2,21
08:15:30.554282 pkt-line.c:80           packet:     sideband< 0000
08:15:30.560775 run-command.c:643       trace: run_command: git --shallow-file  rev-list --objects --stdin --quiet
08:15:30.562081 git.c:418               trace: built-in: git rev-list --objects --stdin --quiet
error: Could not read f0685139ef5b2b715ec4778d4cb527131906f665
fatal: Failed to traverse parents of commit 299a0dd28f0b6509589f6f1b5d58115783d9c851
error: remote did not send all necessary objects
08:15:30.563762 run-command.c:643       trace: run_command: git gc --auto
08:15:30.565485 git.c:418               trace: built-in: git gc --auto

In my case, a parent element could not be found. That information gives you something more to work with. Ultimately, I was able to work around the problem in this case using git fetch --depth=1.