Command-line tool to delete merged Git branches
Project description
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.:
- Arch Linux (AUR) —
# yay -S git-delete-merged-branches
- Gentoo Linux —
# emerge -av dev-vcs/git-delete-merged-branches
- Homebrew —
# brew install git-delete-merged-branches
- NixOS
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
,dev
andstaging
- 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 push
is used with--force-with-lease
so if the server and you have a different understanding of that branch, it is not deleted.- There is no use of
os.system
or shell code to go wrong. - With
--dry-run
you can get a feel for the changes thatgit-delete-merged-branches
would 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.
master
should probably track original upstream'smaster
rather thanmaster
of your fork. - Consider keeping your fork's remote
master
up to date (usinggit push
).
When using GitHub:
- You can make GitHub
delete branches of merged pull requests
for you, to save
git-delete-merged-branches
some 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_branches
instead ofgit-delete-merged-branches
- b) Invoke command
git-dmb
instead ofgit-delete-merged-branches
- c) Control path resolution order through environment variable
$PATH
- d) Invoke
git-delete-merged-branches
with its absolute path. You can runwhich -a git-delete-merged-branches
to see where it's located.
Support
Please report any bugs that you find.
Like this tool? Support it with a star!
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
File details
Details for the file git-delete-merged-branches-7.3.0.tar.gz
.
File metadata
- Download URL: git-delete-merged-branches-7.3.0.tar.gz
- Upload date:
- Size: 41.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5029cda32f1a6f80b103c5dc79c85f88952c772709c539acc94068cf9e97286 |
|
MD5 | 5ce49a4acf3dc8348c58e6dbf4320749 |
|
BLAKE2b-256 | 235be8add6d5598f02d1e6c9c2c33f466c1b054d904af8d9c4900ecee71b7a46 |
Provenance
File details
Details for the file git_delete_merged_branches-7.3.0-py3-none-any.whl
.
File metadata
- Download URL: git_delete_merged_branches-7.3.0-py3-none-any.whl
- Upload date:
- Size: 43.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ea44002fd5432533bc82283f35518c9e3939ab3b671cde7b95d5793e885cfe3 |
|
MD5 | 0df0cd2c37da3e7637b23cc13c60e3f6 |
|
BLAKE2b-256 | 2c49e393380ca173ed98ade97149ac6c2d40a91a46ba41eff9faa745cb981911 |