Remove all git branches expect master.

Deepak
TarkaLabs TIL
Published in
1 min readDec 10, 2018

Slowly my local git repository had accumulated close to 50 branches. I felt like removing every other branch expect master .

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

The above one liner did the deed and what caught my attention was the grep -v command which does an invert-match.

--

--