git-cleanup-branches

Clean up local git branches that track deleted remote branches. Use when asked to "clean git branches", "remove deleted branches", "prune branches", "cleanup stale branches", or when you see branches marked as "gone" in git status. Works on Windows, macOS, and Linux.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "git-cleanup-branches" with this command: npx skills add pickleboxer/skills/pickleboxer-skills-git-cleanup-branches

Git Branch Cleanup

Automatically identifies and removes local git branches that track remote branches that no longer exist (marked as "gone").

When to Use This Skill

  • User asks to "clean up git branches"
  • User wants to "remove deleted branches"
  • User mentions "prune branches" or "cleanup stale branches"
  • Local branches show [origin/branch: gone] status
  • After merging pull requests and deleting remote branches

Prerequisites

  • Git repository initialized
  • Must be on main/master branch (not on a branch you want to delete)
  • Active internet connection to fetch from remote

Workflow

1. Switch to main branch (Required)

git checkout main

Important: You cannot delete a branch you're currently on. Always switch to main/master first.

2. Check current branch status

git branch -vv

Look for branches with [origin/branch-name: gone] - these track deleted remotes.

3. Prune remote tracking references

git fetch --prune

4. Find stale branches

PowerShell:

git branch -vv | Select-String 'gone'

Bash:

git branch -vv | grep 'gone'

5. Delete stale branches

Single branch:

git branch -D <branch-name>

Automated cleanup (PowerShell):

git branch -vv | Select-String 'gone' | ForEach-Object { 
    $branchName = $_.Line.Trim() -split '\s+' | Select-Object -First 1
    git branch -D $branchName
}

Automated cleanup (Bash):

git branch -vv | grep 'gone' | awk '{print $1}' | xargs -r git branch -D

6. Verify cleanup

git branch -vv

Safety Notes

  • Always switch to main/master before cleaning - you can't delete the branch you're on
  • Use -D (force delete) - bypasses merge check
  • Deleted local branches can't be easily recovered
  • Remote branches are NOT affected - this only cleans local copies
  • Backup branches (no remote tracking) won't be deleted by this process

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

laravel-simplifier

No summary provided by upstream source.

Repository SourceNeeds Review
General

internal-comms

No summary provided by upstream source.

Repository SourceNeeds Review
General

git-commit

No summary provided by upstream source.

Repository SourceNeeds Review