Skip to content

Instantly share code, notes, and snippets.

@BenDLH
Created September 8, 2016 09:39
Show Gist options
  • Save BenDLH/a2a2bd167e5b259a0cfdba6f6378f750 to your computer and use it in GitHub Desktop.
Save BenDLH/a2a2bd167e5b259a0cfdba6f6378f750 to your computer and use it in GitHub Desktop.
Open a terminal window and cd into a folder under the repository. Then:
git fsck | awk '{print $3}' > tmp.txt
cat tmp.txt | xargs git show > tmp2.txt
Now open tmp2.txt in editor, locate your lost code, and find the commit-id on top of it. Then apply the code:
git stash apply <commit id>
rm tmp.txt tmp2.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment