Skip to content

Quick start

You don’t have to install anything to try gitsweep — run it straight from npx inside any repository:

Terminal window
npx gitsweep

Requires Node.js ≥ 18 and git on your PATH. To keep it around, install globally instead:

Terminal window
npm i -g gitsweep
# or: pnpm add -g gitsweep

Before deleting anything, see exactly what gitsweep would remove. A dry run changes nothing — it’s the recommended first run:

Terminal window
gitsweep --dry-run
Terminal window
Default branch: main · current: feature-y
Merged into default branch:
✓ feature-x (merged)
✓ hotfix-123 (merged)
Upstream gone:
⚠ old-spike (upstream gone) — force delete
Dry run: 3 branch(es) would be deleted.

Candidates are grouped by why they’re stale. A force delete label means the branch isn’t merged and would need git branch -D — see How it works for what that means.

Happy with the list? Run gitsweep with no flags. It prints the same grouped list and then asks before removing anything:

Terminal window
gitsweep
Terminal window
Delete 3 branch(es)? [y/N]

Type y (or yes) to proceed; anything else aborts without deleting. On success you’ll see each branch confirmed:

Terminal window
deleted feature-x
deleted hotfix-123
deleted old-spike
Swept 3 branch(es).
  • Sweep only one kind of branch: gitsweep --merged or gitsweep --gone.
  • Skip the prompt in scripts: gitsweep -y.
  • Point at a non-standard default branch: gitsweep --main develop.

See the full CLI reference for every flag and exit code.