git remove all remote branches except master code example
Example 1: git delete all branches except master
git branch | grep -v "master" | xargs git branch -D
Example 2: Remove All Local Branches not on Remote
$ git branch -r | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | xargs git branch -d