git-clean-gone

Delete local Git branches with removed remote tracking branches and their worktrees.

Updated Jan 5, 2026
One-click install
npx skills add https://github.com/d3ming/dot-agents --skill git-clean-gone
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-gone
Source: https://github.com/d3ming/dot-agents/tree/main/master/skills/git-clean-gone
Command: npx skills add https://github.com/d3ming/dot-agents --skill git-clean-gone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cleans up stale local Git branches whose remote tracking branches have been deleted and removes any associated worktrees to prevent repository clutter and confusion.

Core Features & Use Cases

  • Identifies local branches marked as gone by synchronizing remote state and inspecting branch status.
  • Locates and removes worktrees tied to gone branches before deleting the branches to avoid dangling references.
  • Protects the current branch and common main branches while reporting removed worktrees and deleted branches.
  • Use Case: After a merge that deleted feature branches on the remote, run this to safely purge the corresponding local branches and worktrees.

Quick Start

Clean up this repository by removing local branches whose remote tracking branches were deleted and delete any associated worktrees.

Frequently Asked Questions about git-clean-gone

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

FAQPage Schema
How do I clean up local git branches whose remote tracking branches were deleted?

To clean up local git branches, synchronize remote state with git fetch --prune, inspect branch status to identify branches marked gone, remove associated worktrees, and force-delete the stale local branches while protecting the current branch.

How does git prune work for removing stale local branches and worktrees?

Git prune works for removing stale branches by syncing remote state to detect branches marked gone, then locating and removing any associated worktrees before force-deleting the local branches to prevent dangling references and repository clutter.

What is the best way to remove git worktrees tied to merged branches?

The best way to remove git worktrees tied to merged branches is to run a cleanup process that inspects branch and worktree listings, removes the worktrees connected to gone branches, and then force-deletes the local branches.

Does this branch cleanup process protect the current branch from being deleted?

Yes, the branch cleanup process protects the current branch and common main branches from deletion, only force-deleting local branches whose remote tracking branches have been removed and reporting the removed worktrees and deleted branches.

Why do I have local git branches marked as gone after a remote merge?

Local git branches are marked as gone after a remote merge because the remote tracking branch was deleted on the remote server, leaving the local branch without an upstream reference until you sync remote state and clean up the stale branches.

Can I delete local git branches without first running git fetch --prune?

No, you need to run git fetch --prune to synchronize remote state and accurately detect branches marked gone before removing associated worktrees and force-deleting local branches, ensuring safe and complete repository cleanup.