Created
October 23, 2013 11:58
-
-
Save andykingking/7117273 to your computer and use it in GitHub Desktop.
Accidentally `git reset --hard`? Get em all back
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# output all files in index that haven't been garbage collected | |
git fsck --cache --unreachable $(git for-each-ref --format="%(objectname)") > badfiles | |
# output all files by showing them via sub-hash | |
FILENUM=1 | |
cat badfiles | cut -c 18-24 | while read cur | |
do | |
git show $cur > $FILENUM | |
let "FILENUM += 1" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment