Last active
May 16, 2022 21:29
-
-
Save kbfreder/9056ccb2465c0b828e11800ed00130de to your computer and use it in GitHub Desktop.
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
# this is intended to live as a function inside ~/.bash_profile | |
function git_del_branches { | |
pattern=$1 | |
im=$2 | |
usage="git_del_branches -p pattern [-i] | |
Match and delete git branches that match <pattern>. | |
Use the -i (--inverse) flag to delete branches that do | |
not match <pattern>" | |
if [ "$pattern" = "-h" ]; then | |
echo "$usage" | |
else | |
if [ "$im" = "" ]; then | |
invert=false | |
else | |
invert=true | |
fi | |
if $invert; then | |
git branch | grep -v "$pattern" | xargs git branch -D | |
else | |
git branch | grep "$pattern" | xargs git branch -D | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment