Holy cow it’s been awhile since I posted anything. I blinked and it’s summer! It’s been pretty busy with a now 2 year old who is definitely getting her personality.
Anywho, this will be a savior for anyone who uses git and has a lot of local branches. Want to clean them up fast and don’t want to do it one branch at a time? I’m here for a quick tip thanks to StackOverflow.
git branch | grep "<pattern>" (preview of the branches based on pattern)
git branch | grep "<pattern>" | xargs git branch -D
I cannot believe how simple this was and saved me hours of time. If you’re paranoid, you can do the first step. Just replace <pattern> with the beginning of branch names you want to delete. For example, I had a lot of feature/mem-
from an old JIRA board. All I had to do was this:
git branch | grep "feature/mem" | xargs git branch -D
And Viola! All branches were deleted locally!
Until next time!