Skip to main content

git-prune

Clean up your local git branches to match the remote with one command. This tool synchronizes local git branches with remote branches by removing orphaned local branches that don't exist upstream.

PyPI - version Python License: MIT

Installation

pip install git-prune

Usage

Basic Usage

Run from the repository you want to prune:

git-prune

This will:

  1. Fetch latest remote references (git fetch -p)
  2. List local-only branches that don't exist on remote
  3. Ask for confirmation before deletion
  4. Delete confirmed branches

Specify Target Directory

Prune a different repository:

git-prune -d /Path/to/repository
git-prune --directory /Path/to/repository

What Git Prune Does

  1. Fetches remote references to ensure up-to-date branch list
  2. Compares local branches against remote branches
  3. Reports which branches exist locally but not on remote
  4. Deletes orphaned branches after confirmation

Example Output

Branches ['feature-old-thing', 'temp-experiment'] do not exist in the origin repository. Would you like to delete them? y/N:

Safety Features

  • Fetches first: Always runs git fetch -p before any deletions to ensure you have the latest remote state
  • Requires confirmation: Never deletes without explicit 'y' approval
  • Protects current branch: Switches to a safe target branch (main/master or first remote branch) before deleting branches you're currently on

How It Works

Git Prune uses git fetch -p to prune stale remote tracking references, then compares local branch refs against remote branch refs to identify branches that should be removed.

Before:

  • Local: main, feature-old-thing, temp-experiment
  • Remote: main, feature-new-stuff

After running git-prune (with confirmation):

  • Local: main
  • Remote: main, feature-new-stuff

License

MIT

Metadata

Release files for git-prune 1.0.2

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-prune 1.0.2
File Size Uploaded Provenance
git_prune-1.0.2.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for git-prune 1.0.2
File Interpreter ABI Platform
git_prune-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / git_prune-1.0.2.tar.gz

Download URL git_prune-1.0.2.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
479c712d2b18fe15ac067e4d38cd27230b25bc924d328432ea70df42c8942427
BLAKE2b-256 checksum
How to use checksums
70fffe73c74ac14754cb4184262094cefa18027b8502352321575a395be9060d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / git_prune-1.0.2-py3-none-any.whl

Download URL git_prune-1.0.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d2ca8bb627eec9d17e72d4429d0567324e82e8a2b001fcb9e8296b0f8e74614
BLAKE2b-256 checksum
How to use checksums
88e10fb293cf35af0855101d32be286a0c0ae1b37f6ef39df755c45e2db2add1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for git-prune 1.0.2

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.

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