A Quick Way to Remove all Local git Branches Except for Master

I create a new branch for each new task, so I can end up with a plethora of branches. This is a quick way to remove all branches except master

By Rob Johnson

Mon Jun 26 2017

dev git

Below is a quick way to remove all git branches on your local machine, except for master. This is really helpful for those of us who commit new branches for each new task.

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

This snippet was written by Adan Alvarado.

commerce 4 seo 3 productivity 1 dev 15 sql 1 tutorial 2 javascript 7 git 2 php 3 analytics 3 projects 3 ux 1 teams 1 mobile 1