• Stars
    star
    858
  • Rank 53,134 (Top 2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”ฅ Command-line tool to delete merged Git branches

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

  • 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โ€ฆ leveraging git cherry)
  • 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, 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 that git-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's master rather than master of your fork.
  • Consider keeping your fork's remote master up to date (using git push).

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:

  • a) Invoke python3 -m git_delete_merged_branches instead of git-delete-merged-branches
  • b) Invoke command git-dmb instead of git-delete-merged-branches
  • c) Control path resolution order through environment variable $PATH
  • d) Invoke git-delete-merged-branches with its absolute path. You can run which -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!

More Repositories

1

grub2-theme-preview

๐ŸŒ‡ Preview a full GRUB 2.x theme (or just a background image) using KVM / QEMU
Python
286
star
2

image-bootstrap

โ›… Creates Linux chroots and bootable virtual machine images; command line tool (Python 3)
Python
245
star
3

jawanndenn

๐Ÿ“… Simple alternative to Doodle polls and scheduling (Python 3, Django 5, some JavaScript)
Python
182
star
4

django-berlin

๐Ÿ€ Ever wondered who's doing Django... in Berlin?
79
star
5

sandwine

๐Ÿท Command-line tool to run Windows apps with Wine and bwrap/bubblewrap isolation on Linux
Python
66
star
6

wnpp.debian.net

๐ŸŒ Code powering website "Debian Packages that Need Lovin'" created in 2009
Python
42
star
7

resolve-march-native

๐ŸŒ Tool to determine what GCC flags -march=native would resolve into
Python
32
star
8

docker-ssl-reverse-proxy

๐Ÿ”’ Easy-to-use auto-SSL reverse proxy as a Docker container based on Caddy and Letโ€™s Encrypt
Python
23
star
9

xiangqi-setup

๐ŸŽฒ Generate razor-sharp Xiangqi (Chinese chess) setup graphics; command line tool + themes
Python
22
star
10

binary-gentoo

๐Ÿฎ Collection of simple CLI tools to help build Gentoo packages on a non-Gentoo Linux host
Python
17
star
11

django-createsuperuserwithpassword

Django management command to create usable super users, programmatically
Python
16
star
12

svneverever

๐Ÿ”ฆ Collects path entries across SVN history (Python)
Python
15
star
13

surrogates

๐Ÿ˜Œ Encode and decode pairs of surrogate characters in Python 3
Python
11
star
14

django-migration-vis

to visualize django migration graphs with GraphVis
Python
11
star
15

golang-berlin

๐Ÿ€ Ever wondered who's doing Golang... in Berlin?
10
star
16

antijack

๐Ÿฅท seccomp-based anti-TTY-hijacking proof-of-concept (prevents TIOCSTI and TIOCLINUX)
C
10
star
17

go-wait-for-it

๐Ÿฆซ Wait for service(s) to be available before executing a command.
Go
9
star
18

visdriver

๐ŸŽฆ visdriver uses Winamp plug-ins to visualize audio; targets Wine on GNU/Linux primarily
C
8
star
19

fetchcommandwrapper

๐Ÿฎ Wrapper integrating aria2 (https://aria2.github.io/) into portage's FETCHCOMMAND for faster downloads (Python)
Python
8
star
20

no-cyclic-imports

โ™ป๏ธ Tool to detect and report on cyclic imports in a Python codebase
Python
8
star
21

mozilla-password-decrypt

๐Ÿ”“ Decrypt passwords stored by Firefox, Thunderbird, Iceweasel, Icedove using libnss3.so
Python
7
star
22

update-notifier-tray

๐Ÿ’ก Update indicator tray icon for Debian and Gentoo; meant to replace gone update-notifier
Python
7
star
23

shared-library-version-bump

๐ŸŒ A web-tool to help with bumping -version-info linker arguments with your upcoming release of a shared library
HTML
6
star
24

rnv

๐Ÿ  Relax NG Compact Syntax validator by David Tolpin; official upstream maintenance repository
C
5
star
25

vue-tristate-checkbox

Vue.js component implementing a cycling tristate checkbox that supports form submission
HTML
5
star
26

extract-hotline-miami-soundtrack

๐ŸŽต Extract soundtrack from Hotline Miami PC game .wad file (OGG Vorbis); command line tool
C
5
star
27

enum

๐Ÿ”ข Command line tool to enumerate values, replacing GNU seq and *BSD jot (moved from https://fedorahosted.org/enum/)
C
4
star
28

svgstrip

๐Ÿ›€ Tool that strips private information from SVG files (Python)
Python
4
star
29

import-watch

Trace module imports and detect/deny cyclic imports at runtime
Python
3
star
30

dsp_restless

The Restless Winamp Plugin (a.k.a. dsp_restless) of 2005
C++
3
star
31

backup-my-hub

๐Ÿ™ Simple command line tool to make local backups of GitHub repositories and gists (Python)
Python
3
star
32

rust-for-it

๐Ÿฆ€ Wait for one or more services (TCP port) to be available before executing a command; Rust version of wait-for-it
Rust
3
star
33

xiangqi-book-example

Example of a book featuring print-quality Xiangqi board setup graphics generated on-the-fly using xiangqi-setup; PDF output download at https://github.com/hartwork/xiangqi-book-example/releases/download/1.0.0/book_1_0_0.pdf
TeX
3
star
34

sdl_video_demo

Demos fast blitting of a video buffer to the screen with scaling while respecting aspect-ratio in C99 for both SDL 2 and SDL 1
C
2
star
35

klogripper

๐Ÿšฝ Kernel log ripper, i.e. a union of dmesg and tail -f (C)
C
2
star
36

newspipe

๐Ÿ“ฐ RSS/Atom aggregation to e-mail. Fork of Newspipe 1.1.9 with SSL and packaging (Python)
Python
2
star
37

slides_shell_we_continue

๐Ÿš Slides for a talk on Bash and the terminal (in German)
CSS
2
star
38

gentoo-workshop-troisdorf-2015-08-01

๐Ÿฎ Slides for a talk on how to write Ebuilds for Gentoo (in German); PDF: http://downloads.trolug.de/2015-09-01_gentoo-workshop-troisdorf_sebastian_pipping_paketierung.pdf
Makefile
2
star
39

slides_python_json_emoji_crash_story

๐Ÿ—ฟ Slides of talk "Python JSON Emoji crash story" at Django Meetup Berlin 2020-02-18; latest PDF: https://github.com/hartwork/slides_python_json_emoji_crash_story/releases/download/v4/python-json-emoji-crash-story-2020-02-18-v4.pdf
Makefile
2
star
40

OpenXiangqi

๐ŸŽฒ Chinese chess (Java, GNU AGPL v3 or later)
Java
1
star
41

out_bridge

The Outbridge Winamp Plugin (a.k.a. out_bridge) of 2005/2006
C++
1
star
42

gen_freeze

The Freeze Winamp Plugin (a.k.a. gen_freeze) of 2006
C++
1
star
43

dsp_freeverb_gpl

The GPL Freeverb Winamp Plugin (a.k.a. dsp_freeverb_gpl) of 2006
C++
1
star
44

flasktop

๐Ÿ” "top in the browser" using Flask and jQuery DataTables (Python, JavaScript)
Python
1
star
45

audio_pump_demo

๐ŸŽ™๏ธ Demos pumping audio from the microphone to headphones/speakers in C99 for PulseAudio, PortAudio and SDL 2
C
1
star
46

beamer-theme-matrix

๐ŸŒ LaTeX Beamer Theme Matrix of 2009 (Bash)
Shell
1
star
47

gen_allmusic

The Allmusic Hotkey Winamp Plugin (a.k.a. gen_allmusic) of 2006
C++
1
star