Frequently asked questions
Git Worktree FAQ
Short, technically accurate answers to common worktree questions.
What is a Git worktree?
A Git worktree is an additional working directory linked to the same repository, allowing another branch or commit to be checked out without another full clone.
Why use Git worktrees instead of cloning a repository?
Worktrees share the repository’s object database and configuration, so they use less space and make parallel branch work faster than maintaining several independent clones.
Can the same branch be checked out in multiple worktrees?
Normally no. Git prevents the same local branch from being checked out in more than one worktree to avoid conflicting updates.
Do Git worktrees share the same .git repository?
Yes. Linked worktrees share the main repository’s object database and most repository-level data, while each worktree keeps its own HEAD, index, and working files.
Where does Git store worktree metadata?
The main repository stores linked-worktree administrative data under its git directory, typically in .git/worktrees/.
Can I manually delete a worktree directory?
You can, but it leaves stale metadata. Prefer git worktree remove; if the directory is already gone, inspect and clean records with git worktree prune.
How do I remove a Git worktree safely?
Commit or stash wanted changes, then run git worktree remove <worktree>. Git refuses normal removal when protected local changes are present.
What does git worktree prune do?
It removes stale administrative records for linked worktrees that are no longer present. Use --dry-run to preview the cleanup.
What does git worktree repair do?
It repairs administrative links after a linked worktree or the main repository has been moved manually.
Do worktrees share dependencies such as node_modules?
No by default. Each worktree has its own files and typically needs its own node_modules unless you deliberately share or cache dependencies.
Do worktrees share environment files?
Only tracked environment files appear automatically. Ignored files such as .env.local usually need to be copied, generated, or linked for each worktree.
How many Git worktrees can I create?
Git does not impose a small fixed limit. Practical limits are disk space, tooling overhead, and how many active branches your workflow can manage clearly.