Remove merged git branches

 

To get a list of all remote branches:

for remote in git branch -r ; do git branch --track $remote; done

To remove remote branches that have been merged into master:

git branch --merged master | grep -v master | cut -d/ -f2- | xargs -n 1 git push --delete origin

And to remove local branches that have been merged into master:

git branch --merged master | grep -v master | xargs -n 1 git branch -d

Thanks to Ben Lobough for these gems.

Up Next:

Build Something.

Build Something.