I’d like to create a git command that will delete any branches that have all commits included in the current branch e.g.
$ git branch
groups
* master
$ git cleanup-branches
deleted groups # all commits are included in master
$ git branch
* master
How would I go about creating this?
You can leverage
git branch -dhere, as it won’t delete any branch not yet merged into your current branch:Just tried this locally and it worked, although it is a little terrifying to watch it work.