环境

git version 1.9.1
Gerrit Code Review (2.11.3)

现象

修改后调用 Git review可以提交到Gerrit上,然后只要一用 git commit --amend修改 Commit Message再提交,就会出现此错误;而如果不修改Commit Message,而只是修改增加文件,那么可以用--amend提交再 git review

error: unpack failed: error Missing tree 8d89499daadf6417347218b630b5cae57e7fa27c
fatal: Unpack error, check server log
To ssh://user1@review.zjc.com:29418/test-project1.git
 ! [remote rejected] HEAD -> refs/publish/master (n/a (unpacker error))
error: failed to push some refs to 'ssh://user1@review.zjc.com:29418/test-project1.git'

解决方案

thin push

有人说

  • 在工程的 .gitreview 下的 Gerrit节点下增加 

disablethinpush=true

  • 在 /etc/git-review/git-review.conf 中添加 

disablethinpush=true

  • 用 

git push --no-thin ...

  • 来解决,因为这是一个BUG
  • 涉及到库更改时候有未关闭的的patch,更新gerrit的数据库

git review来提交而已。捣鼓了半天上面的N种列出来没列出来的解决方案,都失败

好吧,说出来我碰巧得到的一个这种方案

git review --no-thin :失败 

无意间看到 git review -h 有个命令行参数 -n 

执行命令git review -n : 

Please use the following command to send your commits to review: 

    git push gerrit HEAD:refs/publish/master

git push gerrit HEAD:refs/publish/mastergit push --no-thin gerrit HEAD:refs/publish/master

成功了!!!!

好吧,我笨 && 牛人的世界我不懂

结论

加一个结论吧,啰嗦一大堆,其实就2句话是关键 
执行 git review,如果出现错误就执行git push --no-thin gerrit HEAD:refs/publish/master

参考

https://libraries.io/github/savoirfairelinux/git-review 
https://bugs.launchpad.net/git-review/+bug/1332549