delete all local branches except master Mac git branch | grep -v "master" | xargs git branch -D Windows git branch -D @(git branch | select-string -NotMatch "master" | Foreach {$_.Line.Trim()})