Last active
July 19, 2018 23:48
-
-
Save jeromedalbert/62052c692d133608e054d6a3db82ab69 to your computer and use it in GitHub Desktop.
Remove branches just like git rebase --interactive
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
gbDi() { | |
git branch --sort=-committerdate | remove-colors | egrep -v "master|\*" | cut -c3- > /tmp/branches && \ | |
cp /tmp/branches /tmp/branches-to-keep && \ | |
vim /tmp/branches-to-keep && \ | |
comm -23 <(sort /tmp/branches) <(sort /tmp/branches-to-keep) | xargs 2> /dev/null git branch -D | |
} | |
remove-colors() { | |
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment