Sometimes you need to do some spring cleaning on your remote branches (such as GitHub).
To hell with doing it manually!
Fortunately it's an easy fix for us lazy sods.
List all remote branches which have been merged into master
git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | awk '{sub(/origin\//,"");print}'
Remove all remote branches which have been merged into master
git branch -r --merged | grep origin | grep -v '>' | grep -v master | xargs -L1 | awk '{sub(/origin\//,"");print} | xargs git push origin --delete
It just works.
Source
- A mixture of commands from delete all remote branches that have already been merged into master