Skip to content

Instantly share code, notes, and snippets.

@jleehr
Last active September 15, 2016 14:06
Show Gist options
  • Save jleehr/b5faf8e0376eb20e4e77a9195a81ab29 to your computer and use it in GitHub Desktop.
Save jleehr/b5faf8e0376eb20e4e77a9195a81ab29 to your computer and use it in GitHub Desktop.
Restore lost files in git
#!/bin/bash
# 1. git fsck --lost-found
# 2. run this script via bash restore.php
cd PATH_TO/.git/lost-found/other
FILES=*
COUNTER=0
for f in $FILES; do
echo "Processing $f file..."
git show $f > "PATH_TO/recover/$COUNTER.txt"
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment