A convenient command-line tool helping you keep repositories clean.
# 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.:
# yay -S git-delete-merged-branches
# emerge -av dev-vcs/git-delete-merged-branches
# brew install git-delete-merged-branches
# 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.
--effort=3), single or range cherry-picks… leveraging
Deletion is a sharp knife that requires care.
git reflog would have your back in most cases,
git-delete-merged-branches takes safety seriously.
git-delete-merged-branches does for your safety:
- No branches are deleted without confirmation or passing
- Confirmation defaults to "no"; plain
[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.
--dry-run you can get a feel for the changes that
git-delete-merged-branches would be making to your branches.
- Show any Git commands run using
When the repository is a fork (with an upstream remote and a fork remote):
mastershould probably track original upstream's
masterof your fork.
masterup to date (using
When using GitHub:
git-delete-merged-branchessome work on the remote side, if you like.
Utility collection git-extras provides a
simple shell script named
that competes for command
git-delete-merged-branches when both software packages are installed.
To address this conflict you can:
python3 -m git_delete_merged_branchesinstead of
git-delete-merged-brancheswith its absolute path. You can run
which -a git-delete-merged-branchesto see where it's located.
Please report any bugs that you find.
Like this tool? Support it with a star!