| name | worktree |
| description | Git worktree commands and usage. Triggers on 'worktree', 'worktrees', 'create worktree', 'git worktree'. |
| version | 0.2.8 |
Git Worktrees
Git worktrees allow working on multiple branches simultaneously in separate directories.
Commands
Create a worktree
git worktree add <path> -b <new-branch>
git worktree add <path> <existing-branch>
List worktrees
git worktree list
Remove a worktree
git worktree remove <path>
git worktree remove --force <path>
Prune stale references
git worktree prune
Common Patterns
Feature branch worktree
git worktree add ../feature-123 -b feature-123
cd ../feature-123
Hotfix while preserving current work
git worktree add ../hotfix -b hotfix/urgent-fix origin/main
cd ../hotfix
git push
cd -
git worktree remove ../hotfix
Review a PR/MR locally
git worktree add ../review-pr-456 origin/feature-branch
cd ../review-pr-456
cd -
git worktree remove ../review-pr-456
Tips
- Each worktree has its own working directory and index
- You cannot have the same branch checked out in multiple worktrees
- Worktrees share the same
.git objects - efficient disk usage
- Use
git worktree lock <path> to prevent accidental removal