git-branch-cleaner-cli
v1.0.6
Published
Interactive CLI to bulk-delete local Git branches with a protected list
Maintainers
Readme
git-branch-cleaner-cli 🌿
Interactive CLI tool to bulk-delete local Git branches — with a protected list so you never accidentally remove main, prod, or your important branches.
Install
# From npm (once published)
npm install -g git-branch-cleaner-cli
# Or use directly with npx
npx git-branch-cleaner-cliUsage
git-cleaner # Interactive mode — pick branches to delete
git-cleaner --all # Pre-select all deletable branches (still asks to confirm)
git-cleaner config # Manage your protected branches list
git-cleaner --help # Show helpHow it works
- Reads your protected list (stored in
~/.git-cleaner.json) - Shows all local branches except protected ones and your current branch
- You check the ones you want to delete (space to toggle)
- Confirms before deleting
- Lets you choose
-D(force) or-d(safe, merged only)
Protected branches
Default protected: main, master, prod, develop, staging
Your currently checked-out branch is always protected during a session.
Customize your protected list
git-cleaner configThis lets you add, remove, or replace the protected list. Config is saved globally at ~/.git-cleaner.json.
You can also edit it directly:
{
"protected": ["main", "prod", "dev"]
}Equivalent to
git branch | grep -v -E "^\*|main|prod|my-branch" | xargs git branch -D...but interactive, safer, and reusable.
Requirements
- Node.js >= 16
- Must be run inside a Git repository
License
MIT
