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

Rob Johnson

By Rob Johnson

Mon Jun 26 2017

#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 14 # seo 5 # tools 6 # amazon 1 # sql 4 # shopify 9 # javascript 13 # projects 4 # css 2 # git 2 # php 3 # analytics 4 # api 6 # monitoring 2 # python 2 # aws 2