1

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

2 Answers 2

6
git branch | grep "TEST" | xargs git branch -d
2
  • do you have xargs installed?
    – hoijui
    Jul 6, 2015 at 14:49
  • Yup! I just had to modify the keyword search, but it worked! thanks! Jul 6, 2015 at 15:09
0
for branches in `git branch | grep TEST`; 
    do git branch -D $branches; 
    done

try this..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.