Skip to content

🌿 Interactive git branch deletion tool for ZSH with a beautiful UI

License

Notifications You must be signed in to change notification settings

adelbeke/git-clean-branches

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌿 git-clean-branches

Interactive git branch deletion tool for ZSH with a beautiful UI.

git-clean-branches

Features

  • 🎯 Interactive selection - Use checkboxes to select/unselect branches
  • 📊 Rich information - See last commit date and message for each branch
  • 🛡️ Safety first - Automatically protects current branch and main/master
  • Fast and smooth - Powered by gum
  • 🎨 Beautiful UI - Clean, modern interface with colors

Installation

Prerequisites

Install gum:

brew install gum

Oh My Zsh

  1. Clone this repository into Oh My Zsh's custom plugins directory:
git clone https://github.com/adelbeke/git-clean-branches.git \
    $ZSH_CUSTOM/plugins/git-clean-branches
  1. Add the plugin to your .zshrc:
plugins=(... git-clean-branches)
  1. Reload your shell:
source ~/.zshrc

Manual Installation (Any ZSH)

  1. Clone the repository:
git clone https://github.com/adelbeke/git-clean-branches ~/git-clean-branches
  1. Source the plugin in your .zshrc:
source ~/git-clean-branches/git-clean-branches.plugin.zsh
  1. Reload your shell:
source ~/.zshrc

Usage

Basic Usage

git-clean-branches

Or use the short alias:

gcb

Options

git-clean-branches [OPTIONS]

OPTIONS:
    -f, --force     Force delete branches (even if not fully merged)
    -h, --help      Show help message
    -v, --version   Show version

Examples

Safe delete (only merged branches):

git-clean-branches

Force delete (including unmerged branches):

git-clean-branches --force

Using the alias:

gcb -f

How It Works

  1. Lists all branches - Except current branch and protected branches (main, master, develop, development)
  2. Shows information - Displays last commit date and message for each branch
  3. Interactive selection - Use space to select/unselect, enter to confirm
  4. Confirmation - Shows summary and asks for final confirmation
  5. Deletion - Deletes selected branches with progress feedback

Protected Branches

The following branches are automatically protected and won't appear in the list:

  • Current branch (the one you're on)
  • main
  • master
  • develop
  • development

Safety Features

  • Safe delete by default - Uses git branch -d which only deletes merged branches
  • Force option - Use --force to delete unmerged branches with git branch -D
  • Clear feedback - Shows which branches were deleted and which failed
  • Cancellation - Can cancel at any point with Ctrl+C or by saying "No" to confirmation

Troubleshooting

"gum: command not found"

Install gum:

brew install gum

"Not in a git repository"

Make sure you're inside a git repository:

cd /path/to/your/git/repo

Branch won't delete (not fully merged)

Use the force option:

git-clean-branches --force

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

MIT License - see LICENSE file for details

Credits

Built with:

  • gum - A tool for glamorous shell scripts
  • ZSH - The Z shell

Made with ❤️ for developers who like clean repositories

About

🌿 Interactive git branch deletion tool for ZSH with a beautiful UI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages