git-clean deletes branches that are already merged into your base branch (default: main).
It can delete:
- local branches
- remote branches
- both (default)
gitinstalled and available inPATH- Rust
1.74+only if building from source
Using bin (recommended):
bin install aaronflorey/git-cleanWith Cargo from this fork (not crates.io):
cargo install --git https://github.com/aaronflorey/git-clean.git --lockedBuild locally from source:
cargo build --releasePreview and confirm deletion:
git-cleanRun non-interactively:
git-clean -yDelete only local or only remote:
git-clean -l -y
git-clean -r -y-l, --locals Only delete local branches
-r, --remotes Only delete remote branches
-y, --yes Skip confirmation prompt
--dry-run Preview branches without deleting them
-s, --squashes Detect squash-merged branches
-d, --delete-unpushed-branches Delete branches with no upstream that are absent on remote
-R, --remote <remote> Remote name (default: origin)
-b, --branch <branch> Base branch (default: main)
-i, --ignore <branch> Ignore branch (repeatable)
--color <auto|always|never> Control color output (default: auto)
--save-config Save provided flags for this repository
--ignore-config Ignore saved repository config
git-clean supports saved defaults per repository in:
~/.config/git-clean/config.toml
CLI flags always override config values.
Save flags for the current repository:
git-clean --save-config -s -d -i release -i keep-meExample config:
["/Users/you/code/my-repo"]
squashes = true
delete_unpushed_branches = true
remote = "origin"
base_branch = "main"
ignored_branches = ["release", "keep-me"]
delete_mode = "both"
color_mode = "auto"cargo fmt -- --check
cargo test --lockedMIT