Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ebuka_dev/git-branch-cleaner

Joseph-Ebuka6MIT1.0.0

A CLI tool to help manage and clean up Git branches

git, branch, cleanup, cli, git-tools, branch-management

readme

Git Branch Cleaner

A command-line tool to help manage and clean up Git branches in your repository. Simplify your git branch management with interactive selection, safe deletions, and clear status indicators.

Features

  • 🌳 Interactive branch selection with spacebar
  • 🔍 List all branches with status indicators
  • 🗑️ Clean up stale and merged branches
  • 🔒 Safe deletion with protected branches (main/master)
  • 📝 Verbose mode for detailed branch information
  • ✨ Beautiful CLI interface with color coding

Installation

# Install globally using npm
npm install -g @ebuka_dev/git-branch-cleaner

# Or use with npx
npx @ebuka_dev/git-branch-cleaner

Usage

List All Branches

Show all branches in the repository with status indicators:

git-branch-cleaner list-all
  • Current branch is marked with green *
  • Stale branches are shown in red
  • Active branches are shown in gray

Delete Branches

Interactive branch deletion with multi-select:

git-branch-cleaner delete

Use:

  • Spacebar to select/unselect branches
  • Arrow keys to navigate
  • Enter to confirm selection
  • Ctrl+C to cancel

Options:

  • --force: Force delete branches without confirmation

You can also delete specific branches directly:

git-branch-cleaner delete branch1 branch2

List Stale Branches

Show branches whose remote tracking branch is gone:

git-branch-cleaner list-stale

Options:

  • -v, --verbose: Show detailed branch information

Clean Merged Branches

List and optionally delete branches that have been merged:

git-branch-cleaner clean-merged

Options:

  • -v, --verbose: Show detailed branch information
  • --auto-delete: Automatically delete without confirmation

Status Indicators

  • 🟢 *: Current branch
  • 🔴 Red: Stale branch (remote is gone)
  • ⚪ Gray: Normal branch
  • 🟡 Yellow: Warning messages
  • 🟦 Blue: Information messages
  • ✨ Sparkle: Successful deletion

Safety Features

  • Protected branches (main/master) cannot be deleted
  • Confirmation prompt before deletion
  • Clear error messages
  • Interactive selection to prevent mistakes
  • Color-coded status for better visibility

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Joseph Ebuka - ebukaj665@gmail.com

Support

If you find this tool helpful, please consider:

  • Giving it a ⭐ on GitHub
  • Reporting any issues you encounter
  • Sharing it with others who might find it useful