local branches List local branches which have been merged in master git branch --merged master Remove these local merged branches, make sure you are on master and updated to newest git checkout master && git pull origin master git branch --merged master | egrep -v "(^\*|master)" | xargs git branch -d remote branches List remote branches which have been merged in master git branch -r --merged master Remove these remote branches, make sure you are on master and updated to newest git checkout master && git pull origin master git branch -r --merged master | egrep -v "(^\*|master)" | sed 's_ *origin/__' | xargs -I% git push origin --delete %