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)
-
You first must install oh-my-zsh
-
Download or clone git-prune and copy/move to the directory ~/.oh-my-zsh/plugins
-
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)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.
If you're using the zgen framework, add zgen load diazod/git-prune to your .zshrc with your other zgen load commands.
If you're using the zplugin framework, add zplugin light diazod/git-prune to your .zshrc with your other zplugin light commands.
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
The git-prune plugin now supports configurable protected branches to prevent accidental deletion of important branches. By default, the following branches are protected:
masterrelease
You can configure which branches should be protected using the interactive setup:
gprune --setupThis will:
- Show your current protected branches configuration
- Allow you to enter new protected branches (space-separated)
- Save the configuration to
~/.gprune_config
To view your current protected branches configuration:
gprune --configYou can also manually edit the configuration file at ~/.gprune_config:
# Example configuration
GPRUNE_PROTECTED_BRANCHES=(master main release develop)You can perform the removal of the merged local branches by just writing the command:
gprunegprune [ -r | --remote | -b | --both | -s | --setup | -c | --config | -v | --version | -h | --help ] <branch-name><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