Created
December 12, 2011 23:12
-
-
Save nodirt/1469584 to your computer and use it in GitHub Desktop.
Find lost, unreachable commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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