Skip to content

Instantly share code, notes, and snippets.

@nodirt
Created December 12, 2011 23:12
Show Gist options
  • Save nodirt/1469584 to your computer and use it in GitHub Desktop.
Save nodirt/1469584 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