git-cleanup

Analyze and clean up local git branches with dry-run previews.

Updated Feb 2, 2026
One-click install
npx skills add https://github.com/shellicar/claude-config --skill git-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-cleanup
Source: https://github.com/shellicar/claude-config/tree/main/skills/git-cleanup
Command: npx skills add https://github.com/shellicar/claude-config --skill git-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Git cleanup helps you keep local repositories tidy by identifying and removing obsolete branches after merges or remote deletions.

Core Features & Use Cases

  • Local branch assessment and automated deletion suggestions to maintain a clean history.
  • Detect remote status ([gone]), merged, or abandoned branches and guide safe deletions.
  • Dry-run previews and safety checks to prevent accidental data loss.

Quick Start

  1. Backup your repository: git bundle create ~/backup-branches-$(date +%Y%m%d).bundle --all
  2. List branches and identify candidates: git branch -v
  3. Preview deletions (dry-run): git branch --merged main | grep -v '^*' | xargs -I{} bash -c 'echo Would delete {}'
  4. Delete a branch safely after validation: git branch -d <branch-name> or force with -D if needed

Frequently Asked Questions about git-cleanup

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

FAQPage Schema
How do I clean up local git branches safely after merging?

To safely clean up local git branches, identify branches merged into main and use dry-run previews to validate candidates before executing deletion commands. This prevents accidental data loss by confirming branch status prior to removal.

What is the best way to delete local branches tracking remotes that are gone?

Deleting local branches tracking remotes marked as gone involves detecting their remote status and guiding safe deletions. You can preview these changes using dry-run capabilities to ensure no critical active work is lost.

Can I preview git branch deletions before running them?

Yes, you can preview git branch deletions using dry-run capabilities. This analyzes merged, gone, or abandoned branches and outputs a list of suggested deletion candidates without actually modifying your repository history.

How do I back up my repository before removing obsolete branches?

To back up your repository before removing obsolete branches, create a git bundle containing all branches. This archives your local state, allowing you to restore critical data if an abandoned branch is accidentally deleted.

When should I force delete a git branch with -D instead of -d?

You should force delete a git branch with -D instead of -d when the branch is abandoned and not fully merged into main. Safe deletion workflows validate branch status first to protect active work from accidental data loss.