0

So after making a commit to my repo friday I have come in this morning to have this error when doing a git status

error: object file .git/objects/7f/01a815152d84c99ebdffcb048b612a8a4959d2 is empty
fatal: loose object 7f01a815152d84c99ebdffcb048b612a8a4959d2 (stored in     .git/objects/7f/01a815152d84c99ebdffcb048b612a8a4959d2) is corrupt

Whats weird is i cloned this on another machine on Saturday and it was fine, even pushed new changes to it. My question is why do i get this error message? what causes it? Its happening on a frequent basis now on a number of projects and I would like to find the root cause

Has anyone had any experience with this type of error?

Thanks

Baldrick
  • 23,882
  • 6
  • 74
  • 79
Richlewis
  • 15,070
  • 37
  • 122
  • 283

1 Answers1

1

You have a corrupt object in your repo. The simplest thing to do is to abandon it and to revert to one of your non-corrupt backups - you indicated that you have a good clone - use it instead.

If you want to pursue this further, you can try and recover the object from your other non-corrupt repo or maybe from someone else, but this will require some low-level git debugging.

If the object is a blob you can find a quick summary how to try and recover it in Linus' Some tricks to reconstruct blob objects in order to fix a corrupted repository, if however the corrupt object is a tree you are deeper in trouble – you may have to manually rebuild the tree by creating the right staging and using git write-tree.

To decide you can backup and delete the offending object and then run git-fsck --full you should be able to deduce whether you have a corrupt tree or a blob:

$ git fsck --full

broken link from  commit <sha-commit>
              to    tree <sha-tree-1>
missing tree <sha-tree-1>    
... 
broken link from    tree <sha-tree-2>
              to    blob <sha-blob>
missing blob <sha-blob>

Also see,

Community
  • 1
  • 1
mockinterface
  • 14,452
  • 5
  • 28
  • 49