This will delete all branches except for main
and feature/foo-bar
.
git branch -D `git branch | grep -vE 'main|feature/foo-bar'`
This will delete all branches except for master
and branches that begin with kany/SAVE
, and kany/hack
.
git branch -D `git branch | grep -vE 'master|kany/SAVE|kany/hack'`
Found this snippet from Stackoverflow: Can you delete multiple branches in one command with Git?