DEV Community 👩‍💻👨‍💻

Rich Field
Rich Field

Posted on • Updated on

How to delete multiple branches in Git

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

Top comments (0)

12 Rarely Used Javascript APIs You Need

>> Check out this classic DEV post <<