Quickstart¶
Once gitsweeper is installed, there are two commands you'll use day-to-day: preview and cleanup.
See what would be deleted¶
preview is read-only — it lists every remote branch that's already been merged into the main branch, but doesn't delete anything:
$ gitsweeper preview
Fetching from the remote...
These branches have been merged into master:
origin/merged_already_to_master
To delete them, run again with `gitsweeper cleanup`
Delete the merged branches¶
Once you're happy with the preview, run cleanup:
$ gitsweeper cleanup
Fetching from the remote...
These branches have been merged into master:
origin/merged_already_to_master
Delete these branches? (y/n)
Confirm with y to delete. To skip the prompt entirely (useful in scripts and CI), pass --force:
Common variations¶
# Use a different main branch
gitsweeper preview --master main
# Use a different remote
gitsweeper preview --origin upstream
# Skip specific branches (comma-separated, exact names — no globs)
gitsweeper preview --skip "release-2024,hotfix-prod"
# Faster but less thorough — skips squash-merge detection
gitsweeper preview --no-deep-check
# Search deeper history (default is 10,000 commits)
gitsweeper preview --max-commits 50000
# Show debug logging
gitsweeper preview --debug
See the flags reference for every option.
What "merged" means here¶
gitsweeper considers a branch merged if any of these are true:
- Its tip commit appears in the main branch's history (regular merge / fast-forward).
- Its content matches a commit in the main branch via
git cherry/git patch-id(squash merge, rebase, cherry-pick).
The second check is what makes gitsweeper reliable on repositories that use GitHub's Squash and merge button — see Squash-Merge Detection for the details.