git-worktree-remove

Solid

Safely remove a git worktree with branch cleanup and safety checks

AI & Automation 4,957 stars 661 forks Updated today CC-BY-SA-4.0

Install

View on GitHub

Quality Score: 96/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Git Worktree Remove Safely remove a single git worktree with branch cleanup, merge verification, and database branch teardown. **Core principle:** Safety checks first, then clean removal of worktree + branch + DB resources. **Part of:** [Worktree Lifecycle Suite](./git-worktree.md) | [`/git-worktree`](./git-worktree.md) | [`/git-worktree-status`](./git-worktree-status.md) | [`/git-worktree-clean`](./git-worktree-clean.md) ## Process 1. **Validate Target**: Identify worktree to remove 2. **Safety Check**: Protect main/develop branches 3. **Check Merge Status**: Warn if branch has unmerged changes 4. **Check Uncommitted Changes**: Warn if worktree has dirty state 5. **Remove Worktree**: `git worktree remove` 6. **Delete Local Branch**: `git branch -d` (or `-D` with confirmation) 7. **Delete Remote Branch**: `git push origin --delete` (with confirmation) 8. **Database Cleanup Reminder**: Suggest DB branch deletion if applicable 9. **Prune References**: `git worktree prune` ## Safety Checks ### Protected Branches ```bash # Never remove worktrees for these branches (configurable) PROTECTED_BRANCHES="main master develop staging production" if echo "$PROTECTED_BRANCHES" | grep -qw "$BRANCH"; then echo "BLOCKED: Cannot remove worktree for protected branch '$BRANCH'" echo "Protected branches: $PROTECTED_BRANCHES" exit 1 fi ``` ### Uncommitted Changes ```bash cd "$WORKTREE_PATH" if [ -n "$(git status --porcelain)" ]; then echo "WARNING: Worktree has uncommitted cha...

Details

Author
FlorianBruniaux
Repository
FlorianBruniaux/claude-code-ultimate-guide
Created
5 months ago
Last Updated
today
Language
Python
License
CC-BY-SA-4.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category