- Prune branches
- Get all branches that have been merged into master
- Remove master from the list (grep is for an exact match anchoring with ^ and $
- Feed the list of merged branches to xargs and delete them (lower case -d will only delete merged branches)
git fetch -p && git branch --merged master | grep -v '^ *master$' | xargs git branch -d
alias delete-merged-branches="git fetch -p && git branch --merged master | grep -v '^ *master$' | xargs git branch -d"