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