A safety-first CLI tool to automatically clean up stale branches, prune dangling Git objects, and keep your repositories tidy.
- Dry-run by default β see what would happen before any changes are made
- Protected branches β never delete
main,master,develop, or custom patterns - Safety guards β current branch is always skipped, confirmation prompts before deletion
- Stale branch detection β configurable inactivity threshold (default: 90 days)
- Dangling object pruning β clean up unreachable commits, trees, and blobs
- Repository status report β quick overview of branch hygiene and
.gitsize
npm install -g @404-pf/git-broomOr run locally from the project:
npm run dev -- [command]git-broom status # Show repository hygiene report
git-broom clean # Clean stale branches (dry-run by default)
git-broom branches # List branches by state
git-broom objects # Inspect dangling objects| Option | Description | Default |
|---|---|---|
--repo <path> |
Target repository directory | cwd |
--dry-run |
Show what would happen | true |
--no-dry-run |
Apply changes | β |
--yes |
Skip confirmation prompts | false |
--aggressive |
Deep clean with aggressive GC | false |
--verbose |
Show debug output | false |
Show a quick report of your repository's health:
π§Ή Repository Status
ββββββββββββββββββββββββββββββββββββββββ
Current branch main
Total branches 12
Merged branches 5
Stale branches (>90d) 3
Dangling objects 47
Remotes origin
.git size 15.2 MB
Orchestrate a full cleanup:
- Prune remote tracking branches
- Delete merged local branches
- Delete stale branches (configurable days)
- Run garbage collection
git-broom clean # Dry run (default)
git-broom clean --no-dry-run # Apply changes
git-broom clean --yes # Skip confirmation
git-broom clean --stale-days 30 # Custom stale threshold
git-broom clean --aggressive # Aggressive GCList branches categorized by state with name, status, last commit, and subject:
git-broom branches # All branches
git-broom branches --merged # Only merged
git-broom branches --stale # Only stale
git-broom branches --stale-days 60 # Custom thresholdUse --merged to filter for branches already merged into HEAD, and --stale to filter for branches with no commits within the stale threshold (default: 90 days). With no filters, branches are categorized as merged, stale, active, or protected.
Inspect and prune dangling Git objects:
git-broom objects # Show dangling objects
git-broom objects --prune # Remove them
git-broom objects --prune --aggressive # Aggressive cleanupCreate a .gitbroomrc file in your repository or home directory:
{
"protectedBranches": ["main", "master", "develop", "release-*"],
"staleDays": 60,
"dryRun": true,
"aggressive": false,
"skipConfirmation": false,
"verbose": false
}Git Broom is designed with safety as the top priority:
- Dry-run is the default β nothing is deleted unless you explicitly use
--no-dry-run - Protected branches β
main,master,develop, and user-configured patterns are never deleted - Current branch β the checked-out branch is always skipped
- Confirmation prompts β interactive confirmation before any deletion (skip with
--yes) - Remote pruning β remote tracking branches are pruned before evaluating staleness
npm install # Install dependencies
npm run dev -- help # Run in development mode
npm run build # Build for production
npm run typecheck # TypeScript type checking
npm run lint # ESLint
npm run format # Prettier formatting
npm test # Run testsMIT β see LICENSE