git cleanup

07/19/2018

Have you ever ran git branch and realized you have hundreds of old branches on your local machine? This is a super easy way to clean those up.

If you run git config -e --global then paste this in there:

[alias]
    cleanup = "!git branch --merged | grep  -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"

Then you will be able to run git cleanup and it will delete all local branches that have already been merged! Beautiful!

Credit goes to real_ate on this stackoverflow post