Clean up your local git branches to match the remote with one command.
Project description
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.
Installation
pip install git-prune
Usage
Basic Usage
Run from the repository you want to prune:
git-prune
This will:
- Fetch latest remote references (
git fetch -p) - List local-only branches that don't exist on remote
- Ask for confirmation before deletion
- 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
- Fetches remote references to ensure up-to-date branch list
- Compares local branches against remote branches
- Reports which branches exist locally but not on remote
- 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 -pbefore 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_prune-1.0.2.tar.gz.
File metadata
- Download URL: git_prune-1.0.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
479c712d2b18fe15ac067e4d38cd27230b25bc924d328432ea70df42c8942427
|
|
| MD5 |
9b6482785826b0c4096f0c947f3eea96
|
|
| BLAKE2b-256 |
70fffe73c74ac14754cb4184262094cefa18027b8502352321575a395be9060d
|
File details
Details for the file git_prune-1.0.2-py3-none-any.whl.
File metadata
- Download URL: git_prune-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d2ca8bb627eec9d17e72d4429d0567324e82e8a2b001fcb9e8296b0f8e74614
|
|
| MD5 |
b810ad0ca7a36a82d39add2d76ceb65a
|
|
| BLAKE2b-256 |
88e10fb293cf35af0855101d32be286a0c0ae1b37f6ef39df755c45e2db2add1
|