Skip to content
 
 

Repository files navigation

git-clean

CI

git-clean deletes branches that are already merged into your base branch (default: main).

It can delete:

  • local branches
  • remote branches
  • both (default)

Requirements

  • git installed and available in PATH
  • Rust 1.74+ only if building from source

Install

Using bin (recommended):

bin install aaronflorey/git-clean

With Cargo from this fork (not crates.io):

cargo install --git https://github.com/aaronflorey/git-clean.git --locked

Build locally from source:

cargo build --release

Quick Start

Preview and confirm deletion:

git-clean

Run non-interactively:

git-clean -y

Delete only local or only remote:

git-clean -l -y
git-clean -r -y

Common Options

-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

Per-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-me

Example 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"

Development

cargo fmt -- --check
cargo test --locked

License

MIT

About

A Command Line Tool written in Rust for cleaning up local and remote Git branches

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages