user3851283
user3851283

Reputation: 347

How to delete multiple local branches in Git with keyword?

So I have multiple local branches (i.e. "TEST-001, TEST-002, TEST-003, etc...") I was wondering how to delete all local branches that contain the keyword "TEST".

So here's what I got so far.

git branch | grep "TEST" # ->> WORKS

git branch -d | grep "TEST" # ->> FAILS

Upvotes: 1

Views: 705

Answers (2)

kavetiraviteja
kavetiraviteja

Reputation: 2208

for branches in `git branch | grep TEST`; 
    do git branch -D $branches; 
    done

try this..

Upvotes: 0

hoijui
hoijui

Reputation: 3914

git branch | grep "TEST" | xargs git branch -d

Upvotes: 6

Related Questions