@bobfromarcher/gitsweep
v1.0.1
Published
Safely find and prune stale local git branches - fully-merged or remote-gone, never the ones you care about. Zero dependencies.
Maintainers
Readme
gitsweep
Finds stale local branches and clears them out safely. It only targets branches that are fully merged into your default branch or whose upstream has been deleted on the remote. It never touches your current branch, the default branch, or protected names like main, master and develop. No dependencies, no AI.
Install
npm install -g @bobfromarcher/gitsweep
# or once:
npx @bobfromarcher/gitsweepUsage
gitsweep [path] [options]| Option | Description |
| --- | --- |
| (none) | Dry run. Show exactly what would be removed |
| --prune | Delete the sweepable branches (asks for confirmation first) |
| --force, -f | With --prune, skip the prompt and force-delete |
| --base <branch> | Branch to test "merged" against (default: your origin HEAD) |
| --json | Output JSON, delete nothing |
| -h, --help | Show help |
| -v, --version | Show version |
Examples
gitsweep # safe dry run
gitsweep --prune # clean up, with a confirmation
gitsweep --prune -f # clean up, no prompt
gitsweep --base develop # treat develop as the integration branch
gitsweep --json | jq '.sweep[].name'Why it is safe
- Dry run by default. Nothing is deleted unless you pass
--prune. - Merged only. Branches are checked against
git branch --merged, so anything with unmerged work is kept and listed asunmerged. - Hard guards. The current branch, base branch and protected names are excluded before anything is considered.
- Merged branches use a safe
git branch -d. Only branches whose remote is already gone use-D.
Development
git clone https://github.com/bobfromarcher/gitsweep
cd gitsweep
node test/test.jsCI runs the suite on Node 18, 20 and 22 across Linux, macOS and Windows.
License
MIT, bobfromarcher.
