/git-prune

Plugin of oh-my-zsh for deleting branches already merged in your git repositories

Primary LanguageShellGNU General Public License v3.0GPL-3.0

Git prune plugin

This plugin allows you to delete all branches that are already merged in your local repository or/and that were merged in your remote repository (/origin)

Installation

Oh-My-Zsh

  1. You first must install oh-my-zsh

    https://github.com/robbyrussell/oh-my-zsh

  2. Download or clone git-prune and copy/move to the directory ~/.oh-my-zsh/plugins

  3. Edit the following lines in the file .zshrc

	# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
	# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
	# Example format: plugins=(rails git textmate ruby lighthouse)
	# Add wisely, as too many plugins slow down shell startup.

	plugins=(git git-prune)

Antigen

If you use the antigen framework, add antigen bundle diazod/git-prune to your .zshrc file. Antigen will handle cloning the plugin for you automatically the next time you start zsh. You can also add the plugin to a running zsh with antigen bundle diazod/git-prune for testing before adding it to your .zshrc.

Zgen

If you're using the zgen framework, add zgen load diazod/git-prune to your .zshrc with your other zgen load commands.

Zplugin

If you're using the zplugin framework, add zplugin light diazod/git-prune to your .zshrc with your other zplugin light commands.

Manual

If you want to manually install the plugin just copy the files of this repository to the folder ~/.oh-my-zsh/custom/plugins/git-prune

Configuration

Protected Branches

The git-prune plugin now supports configurable protected branches to prevent accidental deletion of important branches. By default, the following branches are protected:

  • master
  • release

Setting up Protected Branches

You can configure which branches should be protected using the interactive setup:

gprune --setup

This will:

  1. Show your current protected branches configuration
  2. Allow you to enter new protected branches (space-separated)
  3. Save the configuration to ~/.gprune_config

Viewing Configuration

To view your current protected branches configuration:

gprune --config

Manual Configuration

You can also manually edit the configuration file at ~/.gprune_config:

# Example configuration
GPRUNE_PROTECTED_BRANCHES=(master main release develop)

EXAMPLE

You can perform the removal of the merged local branches by just writing the command:

gprune

SYNOPSIS

gprune [ -r | --remote | -b | --both | -s | --setup | -c | --config | -v | --version | -h | --help ] <branch-name>

OPTIONS

<branch-name>
	This is the base branch which the plugin will use to compare the merged branches, for example:
	    given the branches "master", "develop" and "example", you are currently in the branch "develop" and the branch named "example" is already merged into it but not into "master" the plugin will delete the branch "example".

-r, --remote
	Defines that only remote branches which were merged should be removed from the repository

-b, --both
	Defines that both remote and local branches which were merged should be removed from the repository

-s, --setup
	Interactive setup to configure protected branches that won't be deleted.
	Use: gprune --setup

-c, --config
	Show current protected branches configuration.
	Use: gprune --config

-v, --version
	Display the current version of the git-prune plugin

-h, --help
	Display usage information and available options