Git Delete All Local Branches Except Specific Branch
Scenario:
Unmanageable amount of local git branches and you want to delete all of the local copies. This is specifically for Windows. You can look at all your local git branches with the most basic of git commands:
git branch

As you can see, manageable list right? What happens when it becomes:

Or gets even worse? Or longer? Of if you’ve got (Because of sheer laziness) hundreds of unmanaged local branches? Ez. Fix is ez. Assuming you do actually want to delete them all as part of a cleanup
- Open Git Bash
- CD to relevant directory
git branch | grep -v BRANCHNAME | xargs git branch -D - Hit return (This will return a few more details

Then ta-da, all gone:
