git delete all branches except master code example

Example 1: git remove all branches except master windows

git branch | %{ $_.Trim() } | ?{ $_ -ne 'master' } | %{ git branch -D $_ }

Example 2: git delete all branches except master

git branch | grep -v "master" | xargs git branch -D

Example 3: how to delete all branches except master

$ git branch | grep -v "master" | xargs git branch -D

Example 4: how to delete all branches in git except master

$ git branch | grep -v '^*' | xargs git branch -D

Tags:

Misc Example