Skip to main content

Determine whether we don't need this clone (or some of its branches) anymore.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_unneeded-1.0.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file git_unneeded-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: git_unneeded-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for git_unneeded-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e937eb52b8a8f26fa308f2f7e71b1240226bb27c57a34775ccb87df02dcee14a
MD5 60aa462dd5469e968b28370a6b1bed5d
BLAKE2b-256 3e36f9b55446d91de9cf49d00cc609358c7a169797abee80fcb4487a0ff61a91

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_unneeded-1.0.4-py3-none-any.whl:

Publisher: publish.yaml on ellieayla/git-unneeded

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page