Home › Git

fatal: 'main' is already checked out at (Git) — how to fix

fatal: 'main' is already checked out at '/home/me/project-hotfix'
fatal: 'main' is already used by worktree at '/home/me/project-hotfix'

Quick fix: Run git worktree list to see where the branch is. Work in that directory, switch the other worktree to a different branch, or remove it with git worktree remove <path>. If the folder was deleted, run git worktree prune.

What it means

A repository can have several working trees (git worktree add), each with its own checked-out branch. Git allows a branch to be checked out in only one of them at a time. Newer Git versions word the message as is already used by worktree at; older ones say is already checked out at. Same meaning.

See all worktrees and their branches:

git worktree list
/home/me/project          a1b2c3d [feature-x]
/home/me/project-hotfix   d4e5f6a [main]

Fix 1: work in the worktree that has the branch

cd /home/me/project-hotfix
git pull

You don't need the branch in two places; commits made in either worktree are in the same repository.

Fix 2: free the branch in the other worktree

Switch that worktree to another branch (or a detached commit):

git -C /home/me/project-hotfix switch --detach
# or
git -C /home/me/project-hotfix switch other-branch

Then check out main where you wanted it.

Fix 3: remove the worktree you no longer need

git worktree remove /home/me/project-hotfix

It refuses if there are uncommitted changes; commit or stash them, or use --force if you are sure they can go.

Fix 4: the worktree folder was deleted manually

If you rm -rf'd the directory, Git still has a record of it in .git/worktrees/, and the branch still counts as checked out. Clean up stale entries:

git worktree prune
git worktree list

If the worktree is on a removable or network drive that's just not mounted, Git won't prune it if it was locked (git worktree lock). Unlock it first with git worktree unlock <path>.

Fix 5: git worktree add for an existing branch

git worktree add ../hotfix main   # fails if main is checked out here

Create a new branch for the worktree instead:

git worktree add -b hotfix ../hotfix main

Or a detached worktree at that commit: git worktree add --detach ../hotfix main.

Override (use with care)

git switch and git checkout accept --ignore-other-worktrees to check out the branch anyway. Then two worktrees share one branch; committing in one makes the other's files out of date compared to its HEAD. Only use it if you understand that.

Other tools

Some IDEs and coding tools create worktrees behind the scenes, so you may have worktrees you didn't add yourself. git worktree list shows them all.

Last updated 2026-12-01.