git branch delete all except code example Example: git delete all branches except master git branch | grep -v "master" | xargs git branch -D