Remove all local Git branches

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

References