Recover a broken Git repo from Time Machine
I had some issue with a git report on my laptop, so I decided to restore it from the Time Machine.
I restored the last working backup, but when I try out some git commands, the repo seems to be damaged and it won't works anymore.
fatal: unable to read 4a0dbcbaa0287ff8fc7a91c75ab1eadfe2f8c548
and the results of git fsck was full of missing references
Dammn! But after some retries, I found out a working solution:
I clone the remote repository in a ../new folder
Then in the broken repostory I did
cat ../new/.git/objects/pack/pack-*.pack | git unpack-objects
This filled up the missing objects in the object database and the repository seems to be fixed.
Thanks to Tilman Vogel for the solution







