← BlogGuides · 3 min

How to switch between git worktrees (there's no git worktree switch)

There's no git worktree switch: you cd. How to find the right folder, jump to it by branch name, and what git switch does when the branch is open elsewhere.

There’s no git worktree switch. Each worktree is an ordinary folder, so you switch to one with cd: git worktree list tells you where it is. What people usually hit is the other thing: git switch <branch> fails with is already used by worktree at '<path>' because that branch is open in another worktree. Go to that path instead. Inside a worktree, git switch works as always for any branch that isn’t open somewhere else.

If worktrees are new to you, start with how to use git worktree; this page assumes you have a couple already.

Git has no switch subcommand for worktrees

I tried it, so you don’t have to:

Terminal window
$ git worktree switch feature/billing
error: unknown subcommand: `switch'
usage: git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]
[--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>]
or: git worktree list [-v | --porcelain [-z]]
or: git worktree lock [--reason <string>] <worktree>
or: git worktree move <worktree> <new-path>
or: git worktree prune [-n] [-v] [--expire <expire>]
or: git worktree remove [-f] <worktree>
or: git worktree repair [<path>...]
or: git worktree unlock <worktree>

The usage text is the complete list of what git worktree does. Moving between worktrees isn’t one of them, because your shell already does it.

Find the folder, then cd

Terminal window
$ git worktree list
~/code/app d750101 [main]
~/code/app-billing d750101 [feature/billing]
~/code/app/.worktrees/search d750101 [feature/search]
$ cd ../app-billing
$ git branch --show-current
feature/billing

Every worktree is a full working folder: your editor, your terminal and your build tools see it as a normal project. cd - takes you back to the previous one.

“is already used by worktree”

This is where git switch and worktrees meet. From the main folder, switching to a branch that a worktree has checked out fails:

Terminal window
$ git switch feature/billing
fatal: 'feature/billing' is already used by worktree at '~/code/app-billing'

Git is telling you where the branch lives. Go there. git checkout and git worktree add refuse the same way, and git branch -d refuses to delete such a branch, which has its own page.

Inside a worktree, switching to a free branch is ordinary:

Terminal window
$ git switch -c feature/billing-v2
Switched to a new branch 'feature/billing-v2'
$ git switch main
fatal: 'main' is already used by worktree at '~/code/app'

The first worked because the branch was new. The second failed because main is open in the main folder.

Jump to a worktree by branch name

With more than two or three worktrees, I’d rather type the branch than remember the path. This function goes in ~/.zshrc or ~/.bashrc:

Terminal window
wt() {
local dir
dir=$(git worktree list --porcelain |
awk -v b="refs/heads/$1" '/^worktree /{p=substr($0,10)} $0=="branch "b{print p; exit}')
if [ -n "$dir" ]; then cd "$dir"; else echo "no worktree has $1 checked out" >&2; return 1; fi
}

It reads git worktree list --porcelain, the format Git keeps stable for scripts, which prints each worktree’s path and branch on separate lines:

Terminal window
$ git worktree list --porcelain
worktree ~/code/app
HEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1
branch refs/heads/main
worktree ~/code/app-billing
HEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1
branch refs/heads/feature/billing
worktree ~/code/app/.worktrees/search
HEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1
branch refs/heads/feature/search

In use, the same in bash and zsh:

Terminal window
$ wt feature/billing
$ pwd
~/code/app-billing
$ wt nope
no worktree has nope checked out

It only finds worktrees that have a branch checked out; a worktree in a detached HEAD has no branch line to match.

Run a command in another worktree without going there

git -C <path> runs Git as if you were in that folder:

Terminal window
$ git -C ../app-billing status --short --branch
## feature/billing

Handy for checking on a worktree where something long is running, without leaving the folder you’re working in.

--ignore-other-worktrees, and why I don’t use it

git switch has a flag that overrides the one-branch-one-worktree rule. Git’s docs: “git switch refuses when the wanted ref is already checked out by another worktree. This option makes it check the ref out anyway” (git-switch docs). It does exactly that:

Terminal window
$ git switch --ignore-other-worktrees main
Switched to branch 'main'
$ git worktree list
~/code/app d750101 [main]
~/code/app-billing d750101 [main]
~/code/app/.worktrees/search d750101 [feature/search]

Now two folders have main checked out, and a commit in either one moves the branch under the other’s files. I switched back straight away and didn’t test what breaks next. If you want a second copy of a branch to look at, git worktree add --detach <path> <branch> gives you one without sharing the branch; see git worktree add.

If you’re switching between worktrees because several AI agents each have one, the worktrees guide for Claude Code and Codex covers how both tools name and place their worktrees.

Questions people ask

How do I switch to another git worktree?

cd into its folder. A worktree is an ordinary directory, and Git has no git worktree switch command. git worktree list shows each worktree's path and branch.

Why does git switch say a branch "is already used by worktree"?

That branch is checked out in another worktree, and a branch can be checked out in only one at a time. Go to that worktree's folder instead, or create a new branch from it with git switch -c.

Can I check out the same branch in two worktrees?

git switch --ignore-other-worktrees lets you, but then two folders move the same branch. Use a second branch or a detached HEAD instead.

Try it on your own repo.

Free for one card at a time.

Get Pro

Seats, you included (2–50)
3
VAT included. Businesses in the EU can add a VAT number on the payment page.Founding price, kept for as long as your subscription runs.

Checking your sign-in…