@lowdep/git-clean-branches
v1.0.0
Published
Interactively clean up merged and stale local git branches — zero dependencies
Maintainers
Readme
git-clean-branches
Interactively clean up merged and stale local git branches. Zero dependencies.
Unlike git branch --merged | grep -v master | xargs git branch -d (Unix-only, no confirmation), this works on Windows and prompts before deleting.
Install
npm install -g git-clean-branchesOr without installing:
npx git-clean-branchesUsage
git-clean-branches # List all non-protected branches
git-clean-branches --merged # Show merged branches, confirm before delete
git-clean-branches --stale 30 # Show branches not touched in 30+ days
git-clean-branches --merged --yes # Delete merged branches without prompting
git-clean-branches --merged --dry-run # Show what would be deletedExample Output
git-clean-branches main
feature/user-auth Add JWT middleware [merged] [3d]
fix/login-redirect Fix redirect after login [merged] [7d]
experiment/graphql Initial GraphQL setup [45d]
wip/notifications WIP: push notifications [62d]
Delete all 4 branches listed above? [y/N/list]Enter y to delete all, n to cancel, or list to confirm each one individually.
Protected Branches
These are never deleted regardless of flags:
main,master,trunk,develop- The currently checked-out branch
- The base branch (auto-detected or set via
--base)
Options
| Flag | Description |
|---|---|
| --merged | Show/delete branches already merged into main |
| --stale <days> | Show/delete branches not touched in N days |
| --base <branch> | Override base branch (default: auto-detect main/master) |
| --force | Use git branch -D (force delete unmerged branches) |
| --yes | Skip confirmation prompt |
| --dry-run | Show what would be deleted, don't delete |
License
MIT
Keywords
git branch cleanup · delete merged branches · stale branches · prune branches · clean git branches · remove old branches · git housekeeping · merged branches · cross-platform · zero dependencies
Built to solve, shared to help — Rushabh Shah 🛠️✨
One of 40+ zero-dependency developer CLI tools — no node_modules, ever.
