Skip to content

Instantly share code, notes, and snippets.

@ivanfretes
Last active December 15, 2022 22:39
Show Gist options
  • Select an option

  • Save ivanfretes/815238f5a8ee408f2ff2eb9eb30a2de3 to your computer and use it in GitHub Desktop.

Select an option

Save ivanfretes/815238f5a8ee408f2ff2eb9eb30a2de3 to your computer and use it in GitHub Desktop.
Recovery commits, tree and blob with bash
#!/usr/bin/env bash
mkdir recovery-git
filehashes='recovery-git/00_hashes.txt'
rm $filehashes
git fsck --unreachable >> $filehashes
while read line; do
wordsInLine=($line)
hash=${wordsInLine[2]}
echo $hash
git show $hash >> "recovery-git/$hash.txt"
echo "-----------------------------------------------------------------"
done < $filehashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment