Remove all git branches except master


When you are working on a large project, it is quite obvious that you will have a large number of feature-branches. Over time, there are a lot of them. You can easily clean up the git tree by deleting all branches except the master branch.

git branch | grep -v "master" | xargs git branch -D

P.S. Be careful! On some projects development code is stored in the develop branch. Obviously it shouldn't be removed.