Skip to main content

git-reclaim

A small, dependency-free disk-reclaim helper for people who keep many git clones side by side. It finds space you can safely get back across a whole tree of repos, and flags clones that are safe to delete because the remote already has everything.

git-reclaim is a git custom subcommand: an executable named git-reclaim on your PATH is runnable as git reclaim.

Scope: git-reclaim does one thing: reclaim disk space across local clones. For multi-repo status and sync (branch, ahead/behind, batch git commands), use gita. For anything needing the GitHub API (bulk listing, health checks, topics, portfolio sites), use gh-toolkit or gh. If you want one verb set across all of them, use gx.

Install

uv tool install git-reclaim
# or
pipx install git-reclaim
# or
pip install git-reclaim

No dependencies beyond Python 3.10+ and git.

git reclaim

git reclaim [-p] [-g] [-r] [-d DIR]

  (default)  dry run: report reclaimable cache space; deletes nothing
  -p         purge the cache directories (any dir git tracks files inside is
             skipped, never deleted)
  -g         compact history: run `git gc` (and `git lfs prune` if installed)
             in every repo and report the .git space reclaimed
  -r         also list repos that are safe to delete (size + last commit + URL)
  -d DIR     directory to scan (default: current directory)

Three ways to free space across a tree of clones:

  • Purge regenerable caches. It finds node_modules, .venv/venv, __pycache__, .pytest_cache, .ruff_cache, .mypy_cache, .next, and target. These rebuild on demand. So git reclaim -p recovers space without touching your source, history, or uncommitted work. If a directory with one of these names turns out to be git-tracked (a committed target/, say), the purge detects that and skips it. dist/ and build/ are deliberately excluded because they are occasionally committed. Re-run npm install or uv sync next time you open a project.

  • Compact .git itself. git reclaim -g runs git gc (plus git lfs prune when git-lfs is installed) in every repo and reports the space recovered per repo. This is standard git maintenance: nothing reachable is deleted, and lfs prune always retains unpushed objects.

  • Find repos that are safe to delete. git reclaim -r lists repos where the remote already has everything: clean working tree, has a remote, no unpushed commits on any local branch, no stashes, and no tags. Rows are sorted by size, with each repo's last-commit date and re-clone URL. Anything not fully synced is counted as "keep" and never listed as safe. Tags are treated conservatively because a local tag ref can be lost even when its commit is on the remote.

How discovery works

It walks the tree but prunes at repo boundaries. The moment a directory contains a .git entry it is recorded as a repo and not descended into. So workspace folders are descended into to find their child repos, while a repo's own working tree (and its node_modules, vendor, submodules, etc.) is not re-scanned. .git is detected as a file or directory, so submodule and worktree clones are recognised too.

Examples

git reclaim              # what could I free from caches? (dry run)
git reclaim -p           # actually purge the caches
git reclaim -g           # repack every repo's .git (git gc)
git reclaim -r           # caches report + list of repos safe to delete
git reclaim -r -d ~/work # scan a different tree

git reclaim only ever deletes caches, and only with -p; -g just repacks history in place. It never deletes a repo. It just reports which are safe, so you stay in control of removing whole clones. Pair it with the re-clone URLs it prints.

Using it from gita

If you manage your clones with gita, you can make git-reclaim feel native. gita loads a user command file from ~/.config/gita/cmds.json and lets custom commands shadow the defaults. Add:

{
  "reclaim": {
    "cmd": "git-reclaim -d .",
    "disable_async": true,
    "help": "reclaim caches / flag safe-to-delete clones"
  }
}

Now gita reclaim (or gita reclaim <group>) runs git-reclaim in each registered repo. No-config alternative:

gita shell 'git-reclaim -d .'

Note this runs it per repo, which suits the cache purge (-p) and git gc (-g) modes. For the cross-tree "what's safe to delete, biggest first" view (-r), run git-reclaim standalone against the parent folder (git reclaim -r -d ~/projects) so you get the single aggregate, size-sorted report.

Development

uv sync --group dev
uv run pytest
uv run ruff check src tests
uv run ruff format --check src tests

CI runs the same checks on every push and pull request.

License

MIT. See LICENSE.

Metadata

Release files for git-reclaim 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 git-reclaim 0.1.0
File Size Uploaded Provenance Actions
git_reclaim-0.1.0.tar.gz 20.6 kB Without provenance Details for git_reclaim-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.1 kB

Release files / git_reclaim-0.1.0.tar.gz

Download URL git_reclaim-0.1.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
07d70ca6aa9ef0a305672c1acde517300dd5706414d2746f9b33015824dfacc1
BLAKE2b-256 checksum
How to use checksums
936869f789c9fc0b6ad786da9740388d1b2eb74870be6b08534bad3ff8e3cfbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

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

Download URL git_reclaim-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b80f30907e5037d9ecc6c4f7e34270562ef7962aaddee265cf2bd0a4dfb25dcb
BLAKE2b-256 checksum
How to use checksums
fae6c877b70b769b05d97e2369eb35320f521a134e54a172f965d91e40d79036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for git-reclaim 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