Skip to content

Instantly share code, notes, and snippets.

@a2ndrade
Created September 27, 2013 21:54
Show Gist options
  • Save a2ndrade/6735774 to your computer and use it in GitHub Desktop.
Save a2ndrade/6735774 to your computer and use it in GitHub Desktop.
Git: Trying to recover a lost file version (after performing destructive changes e.g. rebasing, squashing, amending, etc)
# create dir to put all file version found
mkdir target && cd target
# checkout all "lost" commits and save a file version for each of them
for i in `git reflog | head -75 | awk '{print $1}'`; do cat path_to_file > `git log -1 | head -1 | awk '{print $2}'`; done
# use fdupes to find duplicates, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment