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