- Remove all local branches except for
master
:
git branch | grep -v “master” | xargs git branch -D
- Remove all remote (
origin
) branches except formaster
andHEAD
:
git branch -r | grep origin/ | grep -v 'master$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push origin :$line; done;