| name | using-git-worktrees |
| description | Use when developing multiple features in parallel. Isolated workspaces prevent conflicts and enable concurrent branches. |
SKILL: Using Git Worktrees
Purpose: Parallel development using isolated workspaces for concurrent feature branches
Target: Developers working on multiple features simultaneously
Quick Start
When to Use This Skill
- Developing multiple features concurrently
- Running long-running tests on one branch while working on another
- Isolating experimental changes without stash/commit dance
- Hotfix production while continuing feature work
Quick Reference
git worktree add ../project-feature-1 feature-1
git worktree add ../project-feature-2 feature-2
git worktree list
git worktree remove ../project-feature-1
Core Concepts
Worktree Creation
Basic Syntax:
git worktree add <path> <branch> [<start-point>]
Examples:
git worktree add ../myproject-feature feature-x
git worktree add ../myproject-experiment -b experiment-branch
git worktree add ../myproject-v1.0 -b v1.0-fixes a1b2c3d
Worktree Management
List worktrees:
git worktree list
Remove worktree:
rm -rf ../myproject-feature
git worktree prune
git worktree remove ../myproject-feature
Lock worktree (prevent cleanup):
git worktree lock ../myproject-critical
git worktree unlock ../myproject-critical
Workflow Integration
Parallel Development Pattern:
cd ~/project-main
git checkout -b feature-auth
git worktree add ../project-hotfix -b hotfix-login
cd ../project-hotfix
git worktree add ../project-experiment -b experiment-ui
cd ../project-experiment
cd ~/project-main
Cleanup
After Feature Merge
git checkout main
git merge feature-1
git worktree remove ../project-feature-1
git branch -d feature-1
git worktree prune
Automated Cleanup
git worktree list | while read path commit branch; do
if git merge-base --is-ancestor "${branch:0:-1}" main 2>/dev/null; then
git worktree remove "$path"
fi
done
Verification
Test Worktree Operations
git worktree add /tmp/test-worktree -b test-worktree-branch
git worktree list | grep test-worktree-branch
cd /tmp/test-worktree
git status
git worktree remove /tmp/test-worktree
Troubleshooting
Worktree Already Registered
Error: working tree '.claude' already exists
Solution: Remove existing worktree first
git worktree list
git worktree remove <path>
Detached HEAD in Worktree
Issue: Worktree showing commit hash instead of branch
Fix: Create local branch
cd ../project-worktree
git checkout -b local-branch-name
Related Skills
- git-operations: Push/pull/merge operations across worktrees
- parallel-subagents: Coordinate work across multiple worktrees
- git-master: Git workflow mastery including worktrees
Version: claude-pilot 4.3.0