Clean up local git branches
Author: Ansel Robateau 5/13/2022
I like making things easier through scripting. So I'm sharing a little script that I use while programming.
I follow a git workflow using feature and release branches and two long lived branches (develop, main). When a feature is complete, the feature branch is merged into the develop branch. At which time, the feature branch is obsolete and must be deleted.
I use the following script to clean up my local branches.
This will prompt me with the list of branches to be deleted and ask me if I want to continue. I type 'y' and all branches except my main branches are deleted.
The source code can be found at the following link.