Git push failed, prompt unpack error / unpack failed solution

after you execute the command git commit -amend to amend the commit, then execute git push review HEAD:refs/for/ XXXX to submit the code to Gerrit, but the commit failed and print out the following prompt:

qidi.huang@droid10$ git push review HEAD:refs/for/xxxx

Writing objects: 100% (1/1), 258 bytes | 0 bytes/s, done.  
Total 1 (delta 0), reused 0 (delta 0)  
error: unpack failed: error Missing tree a0abf7e9827e74b7d729485fcd3714bc6a1ce898  
fatal: Unpack error, check server log  
To ssh://[email protected]:29418/kernel/common  
 ! [remote rejected] HEAD -> refs/for/xxxx (n/a (unpacker error))   

we can solve this problem by adding the --no-thin parameter to the submission. In other words, we can use the following command to submit:

$ git push --no-thin review HEAD:refs/for/xxxx

Git push –help) git push –help

--[no-]thin
    These options are passed to git-send-pack(1). A thin 
transfer significantly reduces the amount of sent data when 
the sender and receiver share many of the same objects in 
common. The default is --thin.

failure should be analyzed from the log of Gerrit server. I didn’t check the log (as if I didn’t have permission), but according to other colleagues, the problem may be “Gerrit is not compatible with git. This is because when Git is committed, an open review request is generated in Gerrit, but this request does not belong to any of the commits.

[reference]
[1] git flow and gerrit
[2] git push error: unpack failed: index-pack abnormal exit

Read More: