# You're working on feature-a
# Suddenly need to fix a bug on main
# Options:
# 1. Stash changes (messy)
# 2. Commit WIP (ugly history)
# 3. Clone repo again (slow, uses disk space)# Create a worktree for hotfix
git worktree add ../hotfix main
# Now you have:
# /project <- feature-a branch
# /hotfix <- main branch
# Work on hotfix without touching feature-a!# Add worktree for existing branch
git worktree add ../bugfix bugfix-branch
# Add worktree with new branch
git worktree add -b new-feature ../new-feature main
# List all worktrees
git worktree list
# Remove worktree
git worktree remove ../hotfix
# Prune stale worktrees
git worktree prunegit worktree add ../hotfix main
cd ../hotfix
# fix bug, commit, push
cd ../project
git worktree remove ../hotfixgit worktree add ../v1 release/v1
git worktree add ../v2 release/v2
# Open both in different IDE windowsgit worktree add ../test-main main
cd ../test-main && npm test- No stashing needed
- Faster than cloning
- Shared .git directory (saves disk space)
- Clean mental separation
Learned: December 20, 2025 Tags: Git, Worktrees, Productivity