Git
Remove all local git branches
$ git branch --no-color --merged | grep -v master | grep -v \* | xargs git branch -d
-
List all local branches.
--merged
filter branches that were already merged into a specific branch (master by default) and--no-color a
turn off branch colors, useful for later filtering with grep. -
Filter protected branches with
grep -v <pattern>
. -
Use
xargs
to send the output of the first command as arguments togit branch -d
.
References: