Git Worktree Add
In one line
git worktree add creates a linked working tree for another branch, letting you work on multiple branches in parallel without cloning.
In simple words
git worktree add creates an additional working directory linked to the same repository, checked out to a different branch. Instead of cloning the repo twice or stashing to switch branches, you have multiple worktrees — each on its own branch — sharing the same .git object store. This is ideal for context switching without losing your place.
For example, you are on a feature branch with uncommitted work and need to fix a bug on main. Run git worktree add ../hotfix main, and a new directory ../hotfix appears with main checked out. You fix the bug there, push, and remove the worktree — all without touching your feature worktree. Each worktree has its own HEAD and index but shares objects, so disk usage is low.
Worktrees live alongside the main working tree. List them with git worktree list, remove with git worktree remove <path>, and prune stale entries with git worktree prune. They are perfect for long-running tasks on one branch while you continue on another, and for keeping a clean main checkout for builds.
Example
# Create a worktree for a hotfix on main, in a sibling dir
git worktree add ../project-hotfix main
# Now you have two working trees:
# ./project (on feature branch)
# ../project-hotfix (on main)
cd ../project-hotfix
git switch -c hotfix-123 # create hotfix branch here
# fix the bug, commit, push
git push origin hotfix-123
# Clean up when done
git worktree remove ../project-hotfix
git worktree list # shows remaining worktreesworktree add creates a linked working dir on another branch, sharing the object store. You can work on both branches simultaneously without stashing or cloning.
Related terms
Related Resources
Related Lessons
- Git Worktree
Learn git worktree.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.