I have the same problem. Fortunately, in the same repository on another computer, you can find the git cat-file <hash>
command. However, this file has been packaged.
So i use
git cat-file commit [hash] > make_magic.txt
and copied this file to a corrupt repository, run
cat make_magic.txt | git hash-object -w -t commit
And after that this problem was solved.
This is really a better way than sampling from the start. I have 30,000 fixes and it takes at least 14 days to restore the repository from the start.
source share