| name | git-worktree-workflow-best-practices |
| description | Sub-skill of git-worktree-workflow: Best Practices. |
| version | 1.1.0 |
| category | development |
| type | reference |
| scripts_exempt | true |
Best Practices
Best Practices
Do
- Use descriptive naming convention:
<project>-<purpose>
- Create worktrees in sibling directories (not inside project)
- Commit or stash changes before removing worktrees
- Prune stale worktrees regularly
- Document active worktrees in team communication
- Clean up merged worktrees promptly
Don't
- Create worktrees inside the main project directory
- Leave uncommitted changes in worktrees before removal
- Forget to merge/push changes from worktrees
- Create excessive worktrees (manage actively)
- Use worktrees for long-lived branches (use separate clones)
- Skip the cleanup step after merging
Naming Convention
../project-feature-auth
../project-hotfix-123
../project-review
../project-test
../project-experiment
Workspace Organization
/workspace/
├── project/ # Main development
├── project-feature-a/ # Active features
├── project-feature-b/
├── project-review/ # Review worktree
└── project-archive/ # Completed features (before cleanup)
Cleanup Script
#!/bin/bash
git branch --merged main | grep -v main | while read branch; do
worktree=$(git worktree list | grep "$branch" | awk '{print $1}')
if [ -n "$worktree" ]; then
echo "Removing worktree: $worktree"
git worktree remove "$worktree"
fi
done
git worktree prune