Skip to content

Instantly share code, notes, and snippets.

@bogn83
Forked from nodirt/gist:1469584
Created May 18, 2020 13:42
Show Gist options
  • Save bogn83/25e2dffde7bbab90cc43c287f31b3027 to your computer and use it in GitHub Desktop.
Save bogn83/25e2dffde7bbab90cc43c287f31b3027 to your computer and use it in GitHub Desktop.
Find lost, unreachable commits
# retrieves commit relative date and message
humanify() {
while read hash; do
# echo to trim the new line
echo $( git log -n 1 ..$hash --format='%ci : %h : %s%n%b' )
done
}
# show the commits!
git fsck --unreachable | grep -oP '(?<=commit )\w+' | humanify | sort
# It may show something like
# 2011-12-09 18:50:27 +0500 : 4b524f7 : Fixed bug 12345
# In addition you can grep it:
git fsck --unreachable | grep -oP '(?<=commit )\w+' | humanify | sirt | grep 'bug 123'
# once you have found your commit, merge it
git merge 4b524f7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment