I have lots of branches. These accumulated due to one-branch-per-feature kind of thing.
Here’s how to do it:
git branch --merged | grep -v -e \* | xargs git branch -D
This deletes all the merged branches. I was on develop branch.
\* saves current branch.
How to delete all the branches irrespective of whether they’re merged or not.
git branch | grep -v -e \* -e release -e master | xargs git branch -D
This saves current,
master branch from deletion. You’ll loose your work if you haven’t push it before though.