Skip to main content

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

Example

# git-delete-merged-branches
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
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

Features

  • Supports deletion of both local and remote branches
  • Supports workflows with multiple release branches, e.g. only delete branches that have been merged to all of master, dev and staging
  • Quick interactive configuration
  • Provider agnostic: Works with GitHub, GitLab 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 that git-delete-merged-branches would be making to your branches.
  • Show any Git commands run using --verbose.

Best Practices

  • Consider running git remote update --prune before using git-delete-merged-branches for best results.
  • When the repository is a fork:
    • consider keeping your local master up to date (by making it a tracking branch or by using git pull).
    • consider keeping your fork's remote master up to date (using git push).

Support

Please report any bugs that you find.

Like this tool? Support it with a star!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git-delete-merged-branches-1.1.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

git_delete_merged_branches-1.1.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file git-delete-merged-branches-1.1.2.tar.gz.

File metadata

  • Download URL: git-delete-merged-branches-1.1.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for git-delete-merged-branches-1.1.2.tar.gz
Algorithm Hash digest
SHA256 38d235e92afeb6b2dd98ab37abf3beb0be7e17d8bff50ea30e4e5d705c5e576a
MD5 9c37c3387c7f72187c74f152602fd0e9
BLAKE2b-256 d0b6e00f3dfc0cde3b7a44f0a54883469f60a1b81e65d42c784099656250bb5e

See more details on using hashes here.

Provenance

File details

Details for the file git_delete_merged_branches-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: git_delete_merged_branches-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8

File hashes

Hashes for git_delete_merged_branches-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b14e21dd310643198391104bd0d0d7a298930f6d09ba1bf297938d3c8d47d863
MD5 ff66704f41bf32d88bbfde0f4ab26cbd
BLAKE2b-256 8d821c3c9cbc53fc472f13b89522724618d38a1ca169307317fe57821150ca22

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page