Created
June 15, 2021 09:33
-
-
Save Bradshaw/7ff835ab7108ac17732841eb2261a925 to your computer and use it in GitHub Desktop.
List lost and found commits with a one-liner hash, relative date and commit message
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
#!/bin/bash | |
# Saves your life if you accidentally deleted a branch | |
regex="commit (.*)" | |
git fsck --lost-found | while read f; # unquoted in order to allow the glob to expand | |
do | |
if [[ $f =~ $regex ]] | |
then | |
hash="${BASH_REMATCH[1]}"; | |
echo $(git log --format="%h: %ar - %s" -n 1 $hash) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment