clean all local branches git code example
Example 1: delete all local branches git
$ git branch | grep -v "master" | xargs git branch -D
Example 2: git delete all branches except master
git branch | grep -v "master" | xargs git branch -D
Example 3: clean local branches git
git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -d
Example 4: git delete all local branches
git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D