A powerful CLI tool for managing Git branches with features for safe deletion, interactive selection, and branch cleanup.
- 🔍 List local and remote branches with detailed status
- 🗑️ Safely delete branches with protection for default branches
- 🤝 Interactive mode for selecting multiple branches
- 🧹 Prune stale and merged branches
- 🎨 Color-coded output for better visibility
- 🔒 Protected branches configuration
- 🔄 Remote branch handling
go install github.com/bral/git-branch-delete-go@latest
brew install brannonlucas/tap/git-branch-delete
Download the latest release from the releases page.
# List local branches
git-branch-delete list
# List remote branches
git-branch-delete list --remote
# List all branches
git-branch-delete list --all
# Select branches to delete interactively
git-branch-delete interactive
# or use the shorthand
git-branch-delete i
# Show stale branches
git-branch-delete prune --dry-run
# Delete stale branches (with confirmation)
git-branch-delete prune
# Force delete stale branches
git-branch-delete prune --force
Create ~/.config/git-branch-delete.yaml
:
# Override default branch detection
default_branch: main
# Protect specific branches from deletion
protected_branches:
- main
- master
- develop
# Default remote (default: origin)
default_remote: origin
# Skip confirmation prompts
auto_confirm: false
# Show what would be deleted without actually deleting
dry_run: false
Environment variables are also supported:
GBD_DEFAULT_BRANCH
GBD_DEFAULT_REMOTE
GBD_AUTO_CONFIRM
GBD_DRY_RUN
# Bash
source <(git-branch-delete completion bash)
# Zsh
source <(git-branch-delete completion zsh)
# Fish
git-branch-delete completion fish | source
# PowerShell
git-branch-delete completion powershell | Out-String | Invoke-Expression
- Go 1.22 or later
- Make
# Clone the repository
git clone https://github.com/bral/git-branch-delete-go.git
cd git-branch-delete-go
# Install dependencies
make deps
# Build
make build
# Run tests
make test
make build
- Build the binarymake test
- Run testsmake clean
- Clean build artifactsmake install
- Install to $GOPATH/binmake deps
- Install dependencies
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -am 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT License - see LICENSE file