Skip to content

Instantly share code, notes, and snippets.

@jeromedalbert
Last active July 19, 2018 23:48
Show Gist options
  • Save jeromedalbert/62052c692d133608e054d6a3db82ab69 to your computer and use it in GitHub Desktop.
Save jeromedalbert/62052c692d133608e054d6a3db82ab69 to your computer and use it in GitHub Desktop.
Remove branches just like git rebase --interactive
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