Skip to content

How to delete multiple branches in Git

kildareflare profile image Rich Field github logo 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

twitter logo DISCUSS
markdown guide
Classic DEV Post from Jul 30 '19

What's your favorite question to be asked?

Rich Field profile image
Full stack remote dev that prefers the front end. I build web applications for NPOs and businesses large and small.