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.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_unneeded-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 303a000de4bf45c23090f3ca0b66204e20a1c71e3999fc8dec53a2186b504c35
MD5 c0ddbfc289f8476a5572109bdd4d02bd
BLAKE2b-256 42824ed96352ae42b3dc1cef122d0f7a0a10fa6587961c815137c045b812fec1

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_unneeded-1.0.3-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