Skip to main content

git unneeded

Did you clone a large amount of git repos? Is ~/workspace/ a giant mess? Need to declutter?

If a remote exists and all branches have been pushed (or merged), and you trust the remote git host to stay up, maybe we don't need to keep the local copy. If a branch has been pushed/merged, we don't need to keep them.

But if there's local branch refs for commits that have never been pushed, maybe they should be pushed first. Or at least reviewed.

git unneeded will report whether deleting branches/repo would be safe, or whether there's stuff that needs attention. Doesn't delete anything for you. Can be happily run with a giant shell glob or from xargs.

Install

With uv: uv tool install git-unneeded

With pipx: pipx install git-unneeded

Usage

git unneeded -h
usage: git_unneeded.py [-h] [--color {never,always,auto}] [--debug] [--quiet]
                       [--oneline] [--skip-unknown-directories] [--no-fetch]
                       [--no-search-parent]
                       [directory ...]
Options Values Help
positional arguments
directory
Default: . GIT_DIR. Default current directory.
options
-h --help
Flag. show this help message and exit
--color
Choice: never, always, auto
Default: auto
--debug
Flag. Exact git commands and decisions.
--quiet -q -s
Flag. Just safe/not, no justification.
--oneline
Flag. Just output directory\0True. Implies --quiet.
--skip-unknown-directories
Flag. If a passed directory isn't a git repo, skip it. Not considered a failure.
--no-fetch
Flag. Don't connect to any configured remotes. Local cache might be old.
--no-search-parent
Flag. Don't search up parent directories for .git.

So for the annoying case of too many repos;

$ find ~/workspace -maxdepth 2 -name .git -type d -print0 | xargs -0 git unneeded --no-fetch

Metadata

Release files for git-unneeded 1.0.5

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

Built distribution (wheel)

Table of built distributions (wheels) for git-unneeded 1.0.5
File Interpreter ABI Platform
git_unneeded-1.0.5-py3-none-any.whl Python 3 none any Details

Release files / git_unneeded-1.0.5-py3-none-any.whl

Download URL git_unneeded-1.0.5-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebae1ee7d63696fc49d3e1acd5399bd4bb021245e54e2144e62a578fa03d10ea
BLAKE2b-256 checksum
How to use checksums
904a52e393796f23df5768370a60a27c31e158682916cdddb362ed8dac9536d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.5 This release

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

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