Batch clean up of local git branches

I usually add an alias in my .zshrc file so that I can run a single command to clean up feature branches that are merged into master or develop.

alias gbclean="git branch --merged | egrep -v '(^\*|master|develop)' | xargs git branch -d"

But if you run:

git branch --merged | egrep -v '(^\*|master|develop)' | xargs git branch -d

This will remove all branches that are merged into master or develop.

Leave a Reply

Your email address will not be published. Required fields are marked *