Thursday, March 3, 2016

Remove all merged local branches in Git except master


$ git branch
  a
  b
  c
* master

Here, branch 'c' has not merged with master yet. Let's remove all merged branches:

$ git branch --merged master | grep -v master | xargs git branch -d
Deleted branch a (was ebb9040).
Deleted branch b (was ebb9040).

$ git branch
  c
* master