git-branch-cleanup

Solid

Analyzes and safely cleans up local Git branches. Categorizes branches by merge status, staleness, and remote tracking. Provides interactive selection with safety guards. Use when the user wants to clean up branches, delete old branches, organize Git branches, or asks about which branches can be safely deleted.

Code & Development 386 stars 26 forks Updated 4 months ago MIT

Install

View on GitHub

Quality Score: 83/100

Stars 20%
86
Recency 20%
50
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Git Branch Cleanup Safely organize and clean up local Git branches. Categorizes branches by merge status, staleness, and remote tracking, then guides users through safe deletion. ## Contents - Quick Start - Workflow (Steps 1-5) - Commands Reference - Dry Run Mode - Safety Checklist ## Quick Start 1. Analyze branches (Step 1) 2. Categorize by safety level (Step 2) 3. Display results and ask user which to delete (Step 3) 4. Verify against safety guards (Step 4) 5. Execute deletion after confirmation (Step 5) ## Workflow ### Step 1: Branch Analysis Collect information with these commands: ```bash # Decide base branch (prefer auto-detect; fallback to main) BASE_BRANCH="$( git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@' )" [ -n "$BASE_BRANCH" ] || BASE_BRANCH=main # List all branches with last commit date git for-each-ref --sort=-committerdate refs/heads/ \ --format='%(refname:short)|%(committerdate:relative)|%(upstream:trackshort)|%(contents:subject)' # Merged branches (against base) git branch --merged "$BASE_BRANCH" # Unmerged branches git branch --no-merged "$BASE_BRANCH" # Branches whose upstream is gone (remote deleted) git branch -vv | grep -F ': gone]' || true # List worktrees (branches with '+' prefix in git branch -v have worktrees) git worktree list # Branches with worktrees ('+' prefix indicates worktree association) git branch -v | grep '^+' || true # Branches ahead of upstream (have unpushed commits) gi...

Details

Author
gotalab
Repository
gotalab/skillport
Created
5 months ago
Last Updated
4 months ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category