Deleting redundant git branches!
Every so often I find my local repositories being a mess of old undeleted branches! I generally have two approaches for that:
- Delete all branches but currently active - I rarely need production locally anyway, just make sure you have pushed your most recent stuff online. Easy to substitute what the actual branch to keep is:
git branch | grep -v "dev" | xargs git branch -D
- An alternative option - delete all branches that don't have an online upstream. Very useful to get rid of the branches you've merged in already. As with most git commands you can change a lot with simple flags, I mainly use two variations one for safely deleting (meaning a warning will be displayed if some branches are not fully merged) and one that will force delete all of them
Casing at times makes all the difference.
vs
Member discussion