DEV Community

Rich Field
Rich Field

Posted on • Edited on

5 2

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

E.g.
> git branch | grep "ch100-*"
> git branch | grep "ch100-*" | xargs git branch -D

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay