4

Is there a way to remove references to a missing blob or tree from the history? Here is the output of git fsck --full

broken link from    tree 99fe1a9d46985ca21e88de53a7a290e2b1889722
              to    blob bf70d7b3bf98852e13dd0b3b8499ad5d77f174d9
broken link from    tree e3dbfdf73cb5c9971b95b33da5fc93f5d69acdae
              to    tree 5d02b92042c23945f41c5a895e5fc7f4d5a4988d
missing blob bf70d7b3bf98852e13dd0b3b8499ad5d77f174d9
missing blob 1d918846d68d8a8368cc442b6d5989d275944c39
dangling blob 42c2d0f36c782a48f793f6c381578e0e5611b602
missing tree 5d02b92042c23945f41c5a895e5fc7f4d5a4988d
missing blob e9d2ae0e7d9c30dec40a116a12a97567e29a87d2
dangling blob 1aa5f9b48ea74f4a75aa848c571f223995c36658
dangling blob 94055e2bdcc4399c5563327ff879864c59c95e40
dangling commit 2b46b23ef705d48c03ed2526cad6548d1608644b
missing blob 5f5e29e93984bdb1a4bc3be2ba7ebaba1e595e75

My guess is that either a pull,push, or git move got interrupted. I worked out which files most of the missing blobs referred too, but I cannot recover them since they have been since modified and I have no way of reconstructing the changes (I think; but I'm new to git).

gc, prune, and reflog --expire=now did not help.

Is there a way to tell git "It's OK buddy, I'm fine with the current state of the current HEAD"?

1 Answer 1

4

Interrupting Git will not do this. Having your system crash (reboot) while in the middle of some update might do this, but an ordinary interrupt would not. Disk failure would also do this.

See Repair corrupted git repository and How to fix corrupted git repository? I would just mark this as a duplicate but I'm not sure which of these is a better question-and-answer (though I lean a bit towards the second one myself).

6
  • seems fair. I feel like the second one describes my situation more accurately. Feel free to mark as duplicate.
    – Ole
    Commented Aug 26, 2016 at 19:14
  • Follow-upquestion: When I try to revert to a commit that might be uncorrupted, I get the following message: error: unable to read sha1 file of LWS/code/lis_training_2.R (e9d2ae0e7d9c30dec40a116a12a97567e29a87d2) ... fatal: Could not reset index file to revision '7b9ae3ce'. I do have the missing objects in a remote backup .git folder, but the hashes I get from git --hash-object -w differ from the ones I get in the error message. Any advice?
    – Ole
    Commented Aug 26, 2016 at 19:14
  • What are you feeding to git hash-object -w? Normally if you have a good backup of a missing or corrupt object you can and should simply copy it into place in .git/objects/ (using the original path name, e.g., object abcde... becomes ab/cde...).
    – torek
    Commented Aug 26, 2016 at 19:42
  • If I take the example above, I have LWS/code/list_training_2.R in my backup, but I do not have an object d2ae... in the backup .git/objects/e9. I have two files in the backup .git/objects/, an .idx and a .pack. I'm guessing I need to unpack the latter? This exceeds my git skils and the documentation is not making a lot of sense to me right now.
    – Ole
    Commented Aug 26, 2016 at 19:57
  • 1
    That did it. Great, thanks. For future reference: I unpacked the pack file into a subdirectory of my working directory (see here if, like me, you don't understand the git unpack-objects doc). I then manually copied over the missing blobs into the appropriate .git/objects/... folder. The hint that object abcde is in ab/cde... was crucial.
    – Ole
    Commented Aug 27, 2016 at 0:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.