How to Fix Git Worktree Creation Failing Due to Existing Branch Name Conflict
Quick answer
Trying to create a new worktree for a branch fails because Git refuses to have the same branch checked out in two places at once. Unlike a normal branch...
Trying to create a new worktree for a branch fails because Git refuses to have the same branch checked out in two places at once. Unlike a normal branch checkout, which just moves your working directory's pointer, a worktree is a genuinely separate working directory β and Git's core rule that a branch can only be checked out in one place at a time still applies across all of them.
The Problem
Creating a worktree for a branch that's already checked out somewhere fails immediately:
$ git worktree add ../feature-branch feature/new-ui
fatal: 'feature/new-ui' is already checked out at '/home/user/projects/myapp'
This is confusing if you weren't aware the branch was already checked out anywhere, especially in a repository with multiple existing worktrees you might not be tracking closely.
Why It Happens
Git worktrees let you have multiple working directories attached to a single repository, each checked out to a different branch or commit simultaneously β genuinely useful for working on two features in parallel without stashing or switching context. But Git still enforces its fundamental rule that a given branch can only be the active checkout in exactly one location at a time, since allowing the same branch to be simultaneously edited in two separate working directories would create ambiguity about which set of changes is authoritative. This error appears when:
- The branch is already checked out in your main working directory, and you forgot or didn't realize it before attempting to also check it out in a new worktree.
- The branch is already checked out in a different worktree you created previously and may have forgotten about.
- A stale worktree reference exists β a worktree directory was deleted manually from the filesystem without properly removing it via Git, leaving Git's internal bookkeeping still believing the branch is checked out there.
The Fix
First, check exactly which worktrees currently exist and what each has checked out:
git worktree list
/home/user/projects/myapp a1b2c3d [feature/new-ui]
/home/user/projects/myapp-hotfix 9e8f7d6 [hotfix/urgent-fix]
If the branch is checked out in a worktree you actually want to keep using, simply navigate to that existing worktree instead of trying to create a new one for the same branch:
cd /home/user/projects/myapp
If you specifically wanted a new, separate working directory but don't need it to be the exact same branch, create a new branch instead, optionally based on the one that's already checked out elsewhere:
git worktree add ../feature-branch -b feature/new-ui-v2 feature/new-ui
This creates a new branch feature/new-ui-v2 starting from feature/new-ui's current state, checked out in the new worktree, without any conflict since it's a genuinely distinct branch.
If the branch is checked out in a worktree you no longer actually need, remove that worktree properly through Git rather than just deleting its directory manually:
git worktree remove /home/user/projects/myapp-hotfix
With the worktree properly removed, the branch is now free to be checked out elsewhere:
git worktree add ../feature-branch feature/new-ui
If a worktree directory was already deleted manually from the filesystem (bypassing git worktree remove), Git's internal state can become stale, still believing a branch is checked out somewhere that no longer physically exists. Clean up these stale references explicitly:
git worktree prune
Verify the stale entry is gone:
git worktree list
Still Not Working?
If git worktree prune doesn't resolve a stale reference and the branch still appears checked out somewhere that doesn't actually exist, check Git's internal worktree administrative files directly for a leftover, corrupted entry that pruning didn't catch:
ls -la .git/worktrees/
Each subdirectory here corresponds to a registered worktree β if you find one referencing a path that no longer exists and prune didn't clean it up automatically, you can remove that specific administrative subdirectory manually as a last resort, though this should be done cautiously and only after confirming via git worktree list that it's genuinely the stale entry causing the conflict:
cat .git/worktrees/myapp-hotfix/gitdir # confirm this points at a path that no longer exists
rm -rf .git/worktrees/myapp-hotfix