git commit stopped working - Error building trees

后端 未结 11 1218
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 16:13

I can not commit a change:

$ git commit
error: invalid object 100644 13da9eeff5a9150cf2135aaed4d2e337f97b8114 for \'spec/routing/splits_routing_spec.rb\'
err         


        
11条回答
  •  佛祖请我去吃肉
    2020-12-23 16:27

    This error means that you have a file with hash 13da9eeff5a9150cf2135aaed4d2e337f97b8114, and this hash is not present in .git/objects/../, or it's empty. When this error occurred, I only had this hash in the error, without the file path. Then I tried to do git gc --auto and git reset --hard. After one of these commands (these commands did not fix my problem), I got the path of the file that triggers the error.

    You just need to generate the object hash:

    git hash-object -w spec/routing/splits_routing_spec.rb
    

    For more information see documentation. In the documentation, there is an additional way of repairing this error.

    P.S. This was the only way that was helpful for me.

提交回复
热议问题