How can I recover from a missing blob in a Git repository? How can I recover from a missing blob in a Git repository? git git

How can I recover from a missing blob in a Git repository?


After a bit more digging it turns out that my question is answered here: How to delete a blob from a Git repo - git prune wasn't pruning the stuff I'd wound back because the reflog was still referring to it. Running

git reflog expire --expire=now --all

fixed that. Also, the referenced post gives a mechanism for running git lstree on every commit to find the referenced blob.


I had the same problem (missing blob) and the solution with

git reflog expire --expire=now --all

didn't do the trick. I found my solution in How can I fix a broken repository?.

This simple line,

git hash-object -w <file>

Fixed the missing blob.