git commit stopped working - Error building trees

后端 未结 11 1202
佛祖请我去吃肉
佛祖请我去吃肉 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:36

    If the problematic file is being added by your change you can just remove it from the index and add it again:

    git reset <file> 
    git add <file>
    
    0 讨论(0)
  • 2020-12-23 16:36

    Easy work around solution, if you're not really concerned on the track of the file, you can duplicate the file and remove the original, commit first the deletion and addition, then rename to original again.

    Git should build back again normally

    0 讨论(0)
  • 2020-12-23 16:39
    git hash-object -w spec/routing/splits_routing_spec.rb
    

    With this, git will make a Sha1 for the file.

    0 讨论(0)
  • 2020-12-23 16:40

    git reset --hard should bring your repository back to normal, but you will lose uncommitted changes.

    0 讨论(0)
  • 2020-12-23 16:43

    In my case, I solved it by:

    git reset --mixed
    
    0 讨论(0)
提交回复
热议问题