git-delete-merged-branches
A convenient command-line tool helping you keep repositories clean.
Installation
# pip install git-delete-merged-branches
If you are using one of the distributions below, you can install
git-delete-merged-branches through the respective package manager, e.g.:
| Distribution | Command |
|---|---|
| Arch Linux (AUR) | yay -S git-delete-merged-branches |
| Debian GNU/Linux (>=bookworm) | apt install git-delete-merged-branches |
| Gentoo Linux | emerge -av dev-vcs/git-delete-merged-branches |
| Homebrew | brew install git-delete-merged-branches |
| MacPorts | port install py-git-delete-merged-branches |
| NixOS | nix-shell -p git-delete-merged-branches |
| Ubuntu (>=lunar/23.04) | apt install git-delete-merged-branches |
| Void Linux | xbps-install -S git-delete-merged-branches |
Example
# git-delete-merged-branches
Do you want to run "git remote update --prune" for 1 remote(s):
- origin
Update? [y/N] y
Do you want to run "git pull --ff-only" for 1 branch(es):
- master
Pull? [y/N] y
You are about to delete 6 local branch(es):
- improve-setup-py
- issue-12-enable-ci-for-pull-requests
- issue-5-fix-waste-of-one-second-per-service
- keep-github-actions-up-to-date
- refactoring-one
- simple-ci
Delete? [y/N] y
6 local branch(es) deleted.
You are about to delete 6 remote branch(es):
- origin/improve-setup-py
- origin/issue-12-enable-ci-for-pull-requests
- origin/issue-5-fix-waste-of-one-second-per-service
- origin/keep-github-actions-up-to-date
- origin/refactoring-one
- origin/simple-ci
Delete? [y/N] y
To github.com:hartwork/wait-for-it.git
- [deleted] improve-setup-py
- [deleted] issue-12-enable-ci-for-pull-requests
- [deleted] issue-5-fix-waste-of-one-second-per-service
- [deleted] keep-github-actions-up-to-date
- [deleted] refactoring-one
- [deleted] simple-ci
6 remote branch(es) deleted.
Features
- Supports deletion of both local and remote branches
- Detects multiple forms of de-facto merges
(rebase merges,
squash merges (needs
--effort=3), single or range cherry-picks… leveraginggit cherry) - Supports workflows with multiple release branches, e.g. only delete branches that have been merged to all of
master,devandstaging - Quick interactive configuration
- Provider agnostic: Works with GitHub, GitLab, Gitea and any other Git hosting
- Takes safety seriously
Safety
Deletion is a sharp knife that requires care.
While git reflog would have your back in most cases,
git-delete-merged-branches takes safety seriously.
Here's what git-delete-merged-branches does for your safety:
- No branches are deleted without confirmation or passing
--yes. - Confirmation defaults to "no"; plain
[Enter]/[Return]does not delete. git pushis used with--force-with-leaseso if the server and you have a different understanding of that branch, it is not deleted.- There is no use of
os.systemor shell code to go wrong. - With
--dry-runyou can get a feel for the changes thatgit-delete-merged-brancheswould be making to your branches. - Show any Git commands run using
--verbose.
Best Practices
When the repository is a fork (with an upstream remote and a fork remote):
- Make sure that release branches are tracking the right remote,
e.g.
mastershould probably track original upstream'smasterrather thanmasterof your fork. - Consider keeping your fork's remote
masterup to date (usinggit push).
When using GitHub:
- You can make GitHub
delete branches of merged pull requests
for you, to save
git-delete-merged-branchessome work on the remote side, if you like.
Name clash on "git-delete-merged-branches" with git-extras
Utility collection git-extras provides a
simple shell script named git-delete-merged-branches
that competes for command git-delete-merged-branches when both software packages are installed.
To address this conflict you can:
- a) Invoke
python3 -m git_delete_merged_branchesinstead ofgit-delete-merged-branches - b) Invoke command
git-dmbinstead ofgit-delete-merged-branches - c) Control path resolution order through environment variable
$PATH - d) Invoke
git-delete-merged-brancheswith its absolute path. You can runwhich -a git-delete-merged-branchesto see where it's located.
Support
Please report any bugs that you find.
Like this tool? Support it with a star!
Metadata
Release files for git-delete-merged-branches 7.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_delete_merged_branches-7.7.0.tar.gz | 43.2 kB | Without provenance | Details for git_delete_merged_branches-7.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_delete_merged_branches-7.7.0-py3-none-any.whl | Python 3 | none | any | Details for git_delete_merged_branches-7.7.0-py3-none-any.whl |
Total release size: 89.4 kB
Release files / git_delete_merged_branches-7.7.0.tar.gz
| Download URL | git_delete_merged_branches-7.7.0.tar.gz |
|---|---|
| Size | 43.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56b539a72fe856014a0ca0ab1430d612285fd8dd54fff67e1350bb37431cc264
|
|
BLAKE2b-256 checksum How to use checksums |
38c8da076635e5b5002b8bb5c47add8c91e0e1a96f3e0bfa5772b75782388962
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / git_delete_merged_branches-7.7.0-py3-none-any.whl
| Download URL | git_delete_merged_branches-7.7.0-py3-none-any.whl |
|---|---|
| Size | 46.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
655de71cf666b9cce60ca1e0e6f823d9c97f0d33c06d48d259672653e7c386cc
|
|
BLAKE2b-256 checksum How to use checksums |
6ae30f07bb93872049683d41bb4561f39da7f25b7d01e4573b2fb0b9f27d468c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for git-delete-merged-branches 7.7.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.