Back to all tips

Git Pro Tips

Delete Local Branches in Bulk

🗓️ Published: 4/15/2026 Originally on X: 5/12/2022
Delete Local Branches in Bulk

If your local repo is full of obsolete branches, you can remove all branches except master with one command:

git branch | grep -v master | xargs git branch -D

This is powerful and dangerous, so double-check the branch list before running it.

Discuss this tip on