Git Worktree Answers
Fixes and explanations for common git worktree errors and setup questions.
A git worktree is a second working directory attached to the same repository. Worktrees are how most tools isolate parallel coding agents, so their errors show up often. Each answer below covers one error or question.
Fix "fatal: branch is already used by worktree"
Fix fatal: 'branch' is already used by worktree (or is already checked out at) when adding a git worktree or switching branches.
Remove a Locked Git Worktree
Fix fatal: cannot remove a locked working tree. Unlock it or force removal with git worktree remove -f -f, and prune worktrees whose directory is gone.
Worktree or Clone to Review a Pull Request?
Worktree or fresh clone to review a pull request? Use a detached git worktree on the PR head. It is faster than a clone and leaves your branch alone.
Should Git Worktrees Go Inside the Repo or Next to It?
Put git worktrees next to the repository, not inside it. A nested worktree shows up as untracked and git add -A stages it as an embedded repository.