How to delete multiple branches in Git

kildareflare profile image Rich Field Updated on ・1 min read

I've been a wee bit lazy keeping my local branches up to date.
Thankfully, I learnt today that it's super easy to delete multiple branches at a time.

First run this command to test what branches will be deleted.

> git branch | grep "<pattern>"

Then run this to actually do the delete

> git branch | grep "<pattern>" | xargs git branch -D

> git branch | grep "ch100-*"
> git branch | grep "ch100-*" | xargs git branch -D


Editor guide