My list with local branches was going through the roof so it was time to do some cleanup work.
Let’s start by looking at all our local branches:
$ git branch
All our integrations happen on the “development” branch, so let’s have a look at all branches that are already merged to “development”:
$ git checkout development
$ git branch --merged
Now, we can go through the list and remove all outdated branches one by one using:
$ git branch –d branch-to-remove
Of course as a developer we’ll prefer to automate this. Here is the Powershell script I used:
git branch --merged | ?{-not ($_ -like "*development")} | %{git branch -d $_.trim()}