git-clean-gone-branches

Delete local Git branches whose remote tracking branches no longer exist.

Updated Nov 11, 2023
One-click install
npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill git-clean-gone-branches
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-gone-branches
Source: https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb/tree/main/.opencode/skills/ce/git-clean-gone-branches
Command: npx skills add https://github.com/michaelvolz/redmuffin.Blazor.StaticWeb --skill git-clean-gone-branches

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Local Git branches whose remote tracking branches have been deleted clutter repositories and make navigation harder, so this Skill automates their discovery and removal while respecting any associated worktrees.

Core Features & Use Cases

  • Detection: The included clean-gone script fetches remote state and parses branch tracking details to list gone branches while skipping the currently checked-out branch.
  • Confirmation: Presenting the list prompts for a single yes-or-no decision before taking action, preventing accidental deletions.
  • Safe Deletion: Removing linked worktrees, then force-deleting each branch, keeps the repository tidy after merged or abandoned feature branches are gone.

Quick Start

Ask to clean gone branches, confirm removal, and let the Skill handle pruning and deletions.

Frequently Asked Questions about git-clean-gone-branches

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean up local Git branches after their remote tracking branches are deleted?

To clean up local Git branches, this Skill fetches remote state and parses tracking details to list gone branches, then removes linked worktrees and force-deletes each stale branch after your confirmation.

Why do stale Git branches clutter my repository after fetching and pruning refs?

Stale Git branches clutter repositories because local tracking branches persist even after their remote counterparts are deleted during fetching and pruning refs, making branch navigation harder.

Can I prune gone Git branches that are currently checked out or linked to a worktree?

Yes, you can prune gone Git branches safely because the script skips the currently checked-out branch and removes linked worktrees before attempting the force-deletion of each stale branch.

Does the branch cleanup process require manual confirmation before deleting stale branches?

The branch cleanup process requires manual confirmation, presenting the discovered list of stale branches and prompting for a single yes-or-no decision to prevent accidental deletions.

What's the best way to automate Git branch cleanup for abandoned feature branches?

The best way to automate Git branch cleanup is using a bash script that detects gone remote tracking branches, handles worktree removal, and force-deletes the stale branches after a single confirmation prompt.