cleanup-git

Clean up stale local Git branches and worktrees after user confirmation.

Updated Jun 8, 2022
One-click install
npx skills add https://github.com/joaop21/dotfiles --skill cleanup-git
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-git
Source: https://github.com/joaop21/dotfiles/tree/main/claude/skills/cleanup-git
Command: npx skills add https://github.com/joaop21/dotfiles --skill cleanup-git

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clean up stale local branches and worktrees that have already been merged remotely, reducing repository clutter and confusion for developers.

Core Features & Use Cases

  • Identify local branches whose remote tracking references have been deleted.
  • Detect worktrees on branches that are merged into main.
  • Present a list to the user and delete only the items they select, after explicit confirmation.
  • Skip main and the currently checked-out branch, and avoid worktrees with uncommitted changes.

Quick Start

Scan for stale local branches and worktrees and delete the ones you select.

Frequently Asked Questions about cleanup-git

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

FAQPage Schema
How do I clean up stale local git branches that have been merged remotely?

To clean up stale local git branches, this Skill identifies local branches whose remote tracking references have been deleted and guides you through selecting and confirming which ones to delete. It skips the main and currently checked-out branches for safety.

Can I safely delete git worktrees that are already merged into the main branch?

Yes, you can safely delete merged git worktrees. This Skill detects worktrees on branches merged into main, avoids those with uncommitted changes, and requires explicit confirmation before deletion to ensure no unsaved work is lost.

What is the best way to prune stale git branches and worktrees without losing uncommitted changes?

The best way to prune stale git branches and worktrees safely is using a cleanup process that detects uncommitted changes and skips those worktrees. This Skill automatically skips worktrees with uncommitted changes, protecting the currently checked-out branch and the main branch.

How does branch cleanup automation handle the main branch and currently checked-out worktrees?

Branch cleanup automation handles the main branch and currently checked-out worktrees by skipping them entirely. This prevents accidental deletion of active work, ensuring only stale local branches and worktrees with merged remote references are presented for deletion.

Does this git branch cleanup tool require any dependencies or components to run?

No, this git branch cleanup tool does not require any dependencies or components to run. It operates independently to identify stale local branches and worktrees, guiding you through selection and confirmation before deletion.

Why should I remove stale local branches and worktrees from my Git repository?

You should remove stale local branches and worktrees to reduce repository clutter and confusion. Cleaning up branches that have already been merged remotely keeps your local development environment organized and prevents accidental commits to outdated work.