LOCALLY
git branch --merged | egrep -v "(master|development)" | xargs -n 1 git branch -d
Dry run
git branch --merged | egrep -v "(master|development)" | xargs -n 1 echo
REMOTELY
git branch -r --merged | egrep -v "(master|development)"| grep origin | sed 's/origin\///' | xargs -n 1 git push --delete origin
Dry run
git branch -r --merged | egrep -v "(master|development)"| grep origin | sed 's/origin\///' | xargs -n 1 echo
Once you delete the branch from the remote, you can prune to get rid of remote tracking branches with:
git remote prune origin