git delete all branches merged into master code example
Example 1: git delete merged branches
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
Example 2: git delete all branches except master
git branch | grep -v "master" | xargs git branch -D