What problem does it solve?
This Skill provides a safe way to remove stale and merged local git branches without risking the deletion of important branches, protecting the current branch, default branch, and any worktree-checked-out branch.
Core Features & Use Cases
- Safely Delete Merged Branches: Identifies and removes local branches that are already merged, squash/rebase-merged, or whose remote was deleted.
- Protect Critical Branches: Ensures the current branch, default branch, and any worktree-checked-out branch are never deleted.
- Classification & Review: Lists branches that are merged but need further confirmation before deletion.
- Pruning: Optionally performs a
git fetch --prune to accurately detect remote branches that have been deleted.
Quick Start
Use the git-branch-cleanup skill to safely remove stale branches. First, run the fetch command to ensure all information is up to date:
bash scripts/cleanup-branches.sh --fetch
Review the list of branches and re-run the script with --force to remove them:
bash scripts/cleanup-branches.sh --force