Git Cleanup

My normal development workflow:

I should probably remember to always delete the feature branch on my local machine after it’s merged on GitHub. I never manage this. Sometimes I don’t do this for a very long time and end up with 30+ branches. Then I don’t remember which ones are merged so I don’t know which ones I can delete. Things get messy. So I wrote a quick Git Alias to help me out. To create the alias run the following command from your terminal:

git config --global alias.cleanup '!git checkout master && git branch --merged | grep -v "*" | xargs -n 1 git branch -d'

This alias will automatically delete all branches which have already been merged with master. Just run it from the root of your Git project.

git cleanup

I hope this helps simplify your life as it did mine.

Need some extra development power?

I don't have a lot of time at the moment, but I'm always interested to hear about new projects. I'm particularly interested in EmberJS/Elixir projects and refactoring Rails monoliths. Drop me a line at hello [at] mattbeedle [dot] name or using my contact form

Hire Me

comments powered by Disqus
comments powered by Disqus