hartwork / git-delete-merged-branches

:fire: Command-line tool to delete merged Git branches
https://pypi.org/project/git-delete-merged-branches/
GNU General Public License v3.0
880 stars 15 forks source link
automation cleanup cli cli-tool command-line command-line-tool developer-tool developer-tools git housekeeping python python3

pre-commit Run the test suite Packaging status

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

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:

Best Practices

When the repository is a fork (with an upstream remote and a fork remote):

When using GitHub:

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:

Support

Please report any bugs that you find.

Like this tool? Support it with a star!