This example will show how to remove all Git branches in local except master branch
git branch | grep -v "master" | xargs git branch -D
If you would like to keep master and another-branch then run this:
git branch | grep -v "master\|another-branch" | xargs git branch -D