# Git Worktree Cleanup And Branch Hygiene

> Systematic approach to cleaning up stale git worktrees, orphan branches, and branch hygiene at scale across multiple repos

- Skill: `vamseeachanta/git-worktree-cleanup-and-branch-hygiene` (Agent Skill)
- Install (CLI): `npx skillmds@latest add vamseeachanta/git-worktree-cleanup-and-branch-hygiene`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vamseeachanta/git-worktree-cleanup-and-branch-hygiene/raw
- Safety review: PASS (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: vamseeachanta (https://skillmd.com/u/vamseeachanta)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/vamseeachanta/git-worktree-cleanup-and-branch-hygiene

---


# Git Worktree Cleanup and Branch Hygiene at Scale

When managing automation-heavy repos with accumulated stale worktrees and branches: (1) identify worktrees attached to merged branches via `git worktree list`, (2) remove them with `git worktree remove` before deleting branches (worktrees block deletion), (3) categorize remaining branches by lifecycle (worktree-agent remnants, orphan pre-restructure branches with no common ancestor, superseded feature branches, protected branches), (4) delete merged branches remotely first, then locally, (5) for unmerged branches with value, dry-run merges and resolve conflicts by keeping the current main version if divergence predates recent updates. This prevents disk bloat and merge conflicts from automation artifacts.
