When working on projects with Git Flow or similar workflow where more than one stable branch exists I create a lot of feature branches (
Sometimes I need to clear the list of local branches because it is literally impossible to manage them with dozens of rudimentary branches. I usually delete them one at a time by copying and pasting the branch names into the
git branch -d command. But it takes so long that it’s easier to delete the entire repository and clone again.
I want to delete all of them except
develop in one command (without writing additional shell script/aliases), but all solutions I’ve found on the internet only allow you to delete everything except one branch (
master, for example). This is not an appropriate solution. Has anyone faced a similar problem?
git branch | grep -v " master$" | grep -v " develop$" | xargs git branch -D