Last active
December 20, 2015 19:29
-
-
Save felixrabe/6184057 to your computer and use it in GitHub Desktop.
gitrl
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 | |
n=50 # default | |
if [[ $1 != "do" && $1 != "undo" ]] ; then | |
echo "Usage: gitrl { do [N=$n] | undo }" | |
exit 1 | |
fi | |
n=${2:-$n} | |
if [[ $1 = do ]] ; then | |
git reflog --pretty=tformat:%h | head -n "$n" | sort | uniq | while read b ; do | |
echo git branch -f "reflog-$b" "$b" | |
git branch -f "reflog-$b" "$b" | |
done | |
elif [[ $1 = undo ]] ; then | |
git branch | fgrep reflog- | while read b ; do | |
git branch -D "$b" | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment