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:
$ git worktree switch feature/billingerror: 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
$ 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-currentfeature/billingEvery 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:
$ git switch feature/billingfatal: '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:
$ git switch -c feature/billing-v2Switched to a new branch 'feature/billing-v2'$ git switch mainfatal: '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:
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:
$ git worktree list --porcelainworktree ~/code/appHEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1branch refs/heads/main
worktree ~/code/app-billingHEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1branch refs/heads/feature/billing
worktree ~/code/app/.worktrees/searchHEAD d7501016357cbca268ca49ccd06fa66d5ad0fef1branch refs/heads/feature/searchIn use, the same in bash and zsh:
$ wt feature/billing$ pwd~/code/app-billing$ wt nopeno worktree has nope checked outIt 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:
$ git -C ../app-billing status --short --branch## feature/billingHandy 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:
$ git switch --ignore-other-worktrees mainSwitched 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.