When working on many feature branches, they tend to accumulate in the local Git clone. Even if they get deleted in upstream shared repos, they need to be cleared locally, too, otherwise they will stick around forever.
Here’s a quick one-liner to clean up every branch that is fully merged to main
. It does make sure not to delete main
and develop
, though.
git branch -d $(git branch --merged main | grep -vE '(^\*|master|main|develop)')
Continue reading