Last Updated: February 25, 2016
·
794
· raysrashmi

To get your lost commits in git

To find lost commits in git just do following -:

git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d\  -f3 | xargs -n 1 git log -n 1 --pretty=oneline > .git/lost-found.txt

Now read all commits in .git/lost-found.txt

To bring back

git checkout <SHA>