Skip to main content

branchreap

Safely reap merged & gone-upstream git branches. After a few months, git branch becomes a graveyard: dozens of feature/* that shipped long ago, and tracking branches whose remote was deleted the moment the PR merged. branchreap finds the ones that are actually safe to delete — and only those. Zero dependencies, pure standard library.

# Run without installing:
pipx run branchreap              # scan (read-only)

# Or install it:
pip install branchreap
branchreap clean                 # reap, with a confirmation prompt

What it reaps

  • Merged branches — local branches fully merged into your default branch.
  • Gone branches — tracking branches whose upstream was deleted ([gone]), as long as they carry no unmerged work.

What it will never touch

  • the current branch
  • the default branch (main / master / whatever origin/HEAD points at)
  • unmerged or unpushed work, or any branch with commits of its own — unless you explicitly pass --include-unmerged (and even then, never the current or default branch)

That safety floor is the whole point: run it without reading the docs and the worst case is it deletes a branch git itself considers fully merged.

Why not git branch --merged | xargs git branch -d?

Because that one-liner misses gone-upstream branches, happily lists main, and does nothing about the "is this actually safe?" question. branchreap does merged and gone in one pass, protects the branches you'd regret losing, and runs instantly with pipx (or npx — there's a byte-for-byte twin on npm), no toolchain to install.

Usage

branchreap                      # scan (read-only, default)
branchreap scan --json          # machine-readable
branchreap clean --dry-run      # preview exactly what would be deleted
branchreap clean                # delete, with a confirmation prompt
branchreap clean --yes          # delete, no prompt (scripts / aliases)

Options

--main <branch>       Override the detected default branch
--fetch               Run 'git fetch --prune' first, so 'gone' status is fresh
--include-unmerged    Also reap gone branches with unmerged commits (uses -D)
--json                Machine-readable scan output
-y, --yes             Skip the confirmation prompt
--dry-run             Show what would be deleted, delete nothing

Example

$ branchreap

default branch: main

  ✗ feature/old-login          merged         merged into main
  ✗ fix/typo                    gone           upstream gone · merged into main
  ────────────────────────────────────────────────────────
  2 reapable  (1 merged · 1 gone)  ·  4 kept

  1 gone branch(es) held back (unmerged commits). Use --include-unmerged to reap.

Exit codes

Code Meaning
0 ok
2 error (not a git repo, bad args, or a deletion failed)

License

MIT

Metadata

Release files for branchreap 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for branchreap 0.1.0
File Size Uploaded Provenance Actions
branchreap-0.1.0.tar.gz 10.4 kB Without provenance Details for branchreap-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for branchreap 0.1.0
File Interpreter ABI Platform Actions
branchreap-0.1.0-py3-none-any.whl Python 3 none any Details for branchreap-0.1.0-py3-none-any.whl

Total release size: 20.2 kB

Release files / branchreap-0.1.0.tar.gz

Download URL branchreap-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ed9184b1961043776d2db0edfa467369ab98bb5d02277dc5badfda001127d43a
BLAKE2b-256 checksum
How to use checksums
d0bfdef07ad630b596c4dddbf6643a162eb1538cbeb7f3c61158e6a0b9d4e8e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / branchreap-0.1.0-py3-none-any.whl

Download URL branchreap-0.1.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b420e89d2e0a092485ba1167f8b0590ac7198e97ce1fd1243cdaff7c9a4e3a30
BLAKE2b-256 checksum
How to use checksums
ae3c1a6fbfd7944be535b378982d6ad568db557945cc1ec4a8130d283e661738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for branchreap 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page