how-to ยท git

How to delete git branches by regular expression?


You want to delete plenty of branches in 1 line, e.g. you want to delete all release branches, named like: "release-1.0.0", "release-1.0.1" and so on


git branch -D `git branch | grep -E 'release-.*'`  

Of course you can use any regular expression wildcard which are supported by grep -E

Read also

Grep regular expression manual

Git guide

comments powered by Disqus