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