git-delete-squashed
This is a tool that deletes all of your git branches that have been "squash-merged" into master.
This is useful if you work on a project that squashes branches into master. After your branch is squashed and merged, you can use this tool to clean up the local branch.
Usage
You can install the tool as a Node.js package from NPM. (The package code is in this repo.)
Additionally, you can specify an alternate branch to check for squashed merges, as well. This is useful for different names of trunk branches like main
or develop
.
$ npm install --global @mtripg6666tdr/git-delete-squashed
$ git-delete-squashed
$ # or simply
$ gds
$ # Specify a different branch name like so
$ git-delete-squashed main
Alternatively, you can create .gds
(or .git-delete-squashed
) file to specify your default branch name.
.git-delete-squashed
{
"namespace": "@mtripg6666tdr/git-delete-squashed",
"defaultBranch": "main"
}
namespace
is optional key.
Details
To determine if a branch is squash-merged, git-delete-squashed creates a temporary dangling squashed commit with git commit-tree
. Then it uses git cherry
to check if the squashed commit has already been applied to the default branch. If so, it deletes the branch.
Credit
This is a fork of git-delete-squashed. I appreciate the owner and all contributors.