git-clean-gone-branches

Identify and delete local Git branches with deleted remote tracking branches.

434|33|Updated Jul 27, 2025
One-click install
npx skills add https://github.com/udecode/kitcn --skill git-clean-gone-branches-udecode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-gone-branches
Source: https://github.com/udecode/kitcn/tree/main/.agents/skills/git-clean-gone-branches
Command: npx skills add https://github.com/udecode/kitcn --skill git-clean-gone-branches-udecode

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Clean up local Git branches whose remote tracking branch has been deleted, including any associated worktrees, reducing clutter and preventing confusion.

Core Features & Use Cases

  • Discover gone branches by parsing git branch -vv after a git fetch --prune to identify branches with [origin/...: gone].
  • Present the list to the user for a single-confirmation decision, then delete all selected branches and any related worktrees.
  • Safe handling: never delete the currently checked-out branch and remove worktrees before deleting branches when necessary.

Quick Start

Run the git-clean-gone script to remove all local branches whose remote tracking branch is gone.

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 deleting remote ones?

To clean up local Git branches, run a fetch with prune to identify branches whose remote tracking branch is gone, then confirm and delete them safely along with any associated worktrees.

What's the best way to remove stale Git worktrees linked to deleted branches?

The best way to remove stale worktrees is to parse branch tracking statuses, present the list of gone branches for a single confirmation, and remove worktrees before deleting the branches to prevent data loss.

How does Git identify local branches that have a gone remote tracking branch?

Git identifies gone branches by parsing the output of git branch -vv after a fetch, looking for branches marked with [origin/...: gone] to signal the remote tracking branch has been deleted.

Can I delete multiple stale Git branches and worktrees with a single confirmation?

Yes, you can delete multiple stale branches and worktrees with a single confirmation step, safely removing all selected branches while ensuring the currently checked-out branch is never deleted.

Does removing stale Git branches protect my current working directory from deletion?

Yes, safe handling validates the local repository state before deleting branches, ensuring the currently checked-out branch is never removed and worktrees are safely detached prior to branch deletion.

Why do my local Git branches still exist after the remote branch is deleted?

Local Git branches persist after remote deletion because they are independent copies, requiring a fetch with prune to update tracking statuses and identify them as gone before they can be safely removed.