git worktree vs branch: they are not alternatives

This question is asked constantly and rests on a false premise. A branch and a worktree are not two ways to do the same thing. A worktree is a place to check a branch out, and every worktree you create has a branch in it.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

A branch is a named pointer to a commit. With the default ref backend it is a 41-byte file. A worktree is a working directory with a checkout of one, and every worktree has a branch or a detached commit in it. The real choice is not branch versus worktree; it is switching branches in one directory versus keeping several directories checked out at once.

What you need to know
  • A branch is a pointer to a commit. It is 41 bytes on disk.
  • A worktree is a working directory. Every worktree checks out a branch or a commit.
  • You never choose one instead of the other. You always use branches.
  • The real question is switching versus several directories at once.
  • Switching wins for sequential work, which is most work.
  • Worktrees win when the work is genuinely concurrent, which is what agents made normal.

The category error

A branch is a name that points at a commit. A worktree is a directory with files in it. They sit at different layers of git, which is why "should I use a worktree or a branch" has no answer: you use both, always, in every worktree you create.

Two different things, side by side.

BranchWorktree
IsA named pointer to a commitA directory with a checkout
Costs on disk41 bytesA copy of your working files
Lives in.git/refs/heads/ or packed-refsThe filesystem, plus a small admin directory
How many at onceThousands, comfortablyA handful, realistically
Created bygit branch, git switch -cgit worktree add
Can exist without the otherYes, easilyNo. It checks out a branch or a commit
Deleting it losesNothing, until the reflog expiresAnything uncommitted in that directory
A branch really is a 41-byte file: forty hex characters and a newline.
$ wc -c .git/refs/heads/feature-auth
      41 .git/refs/heads/feature-auth

$ cat .git/refs/heads/feature-auth
ad7da8005b8d1a2c9f0e4b7c3d6e9f1a2b3c4d5e

The question people actually mean

Rewrite the query and it becomes answerable: is it better to keep one working directory and switch, or to keep several directories checked out at the same time?

The comparison that has a real answer.

One directory, switchingSeveral worktrees
Disk usedOne checkoutOne checkout per worktree
DependenciesInstalled onceInstalled once per worktree
Cost of changing taskCommit or stash, switch, rebuildcd
Two things in flight at onceNoYes
Editor and language server stateDiscarded on every switchPreserved per directory
A long test runBlocks the switchRuns while you work elsewhere
Reviewing a colleague branchStash your work firstOpen a second window
Two agents editingThey collide silentlyIsolated
Mental overheadLow: one place to lookReal: N places to remember

Switching is correct for sequential work, and sequential work is most work. You finish one thing, then start another. One directory is simpler in every respect, your dependencies are installed once, and there is exactly one place to look for anything.

Worktrees are correct when the work is genuinely concurrent: a long build or test run you do not want to block on, a review you need to do without abandoning what you have open, or an agent working on one task while you work on another.

Worktree, stash, or a second clone

Three ways to look at something else without losing what you have. They are not equivalent, and the differences show up under pressure.

Stash and switchSecond cloneWorktree
Your work isOn a stack you might forgetUntouchedUntouched
Cost to set upNothingA full clone plus installA checkout plus install
Both visible at onceNoYesYes
Commits visible in the othern/aOnly after push and fetchImmediately
Rebuild after movingUsuallyNoNo
RiskA forgotten stash entryTwo repos drifting apartDisk, and directories to track

Which to use, by situation

The decision, without the theory.

SituationUse
Finish task A, then start task BSwitch branches
Quick hotfix, then straight backCommit and switch, or a throwaway worktree
Review a pull request while keeping your workWorktree
Long test or build run, want to keep workingWorktree
Compare two branches side by side in an editorWorktree
Bisecting while continuing to developWorktree, with --detach
One agent, and you are watching itEither
Two or more agents at onceWorktrees, always
Fifty branches you might touch this quarterBranches. Worktrees are for the two you are on today

What a worktree actually costs

The reason this question gets asked at all is that branches feel free and worktrees do not. That instinct is correct, but the bill is smaller and more specific than people assume.

What each additional worktree does and does not cost.

You pay forYou do not pay for
A checkout of the tracked filesA second object database
A dependency install, unless you share a storeRe-fetching history from the remote
A rebuild of anything gitignoredA second set of remotes to keep in sync
A small admin directory under .git/worktrees/Duplicated branches, tags or config
One more directory to keep track ofAnything at all when it is idle

The first two rows are the whole story. Source files are usually a fraction of a repository, because the object database holding every version of them is the large part and it is shared. Dependency directories often are not a fraction of anything, which is why a content-addressed package manager changes the answer: pnpm keeps one global store and hard-links into each worktree, so the second install is near-free in disk terms.

Does each agent need its own branch, or just its own worktree?

Both, and you get the branch for free, because a worktree has to check out something. The only alternative git offers is --detach, and for an agent that is a trap.

Branch per agent taskDetached HEAD
Commits reachable by nameYesNo
Push and open a pull requestNormalNeeds a branch first
Survives removing the worktreeYesOnly as a dangling object
Shows up in git branchYesNo
Right forAny work you intend to keepReading a tag, bisecting

The naming convention matters more than it sounds once several agents are running. Pick a consistent shape, agent/<ticket> or feature/<topic>, and keep the number of path segments constant. Mixing fix and fix/login in one repository produces cannot lock ref errors, because git refs are stored as a directory tree and a name cannot be both a file and a directory.

What agents changed

For most of git history, genuinely concurrent work was rare, because a person does one thing at a time. Worktrees stayed a curiosity for a decade for exactly that reason. Agents removed the constraint, and the concurrency they introduce is the unattended kind: files changing while you are looking somewhere else.

A branch alone does not fix that, which is the practical answer to the question this page is named after. Two agents on two branches in one directory are still two agents in one set of files. The branch is the label on the result; the worktree is the isolation that makes the result meaningful.

Questions people ask

A branch is a named pointer to a commit and costs 41 bytes on disk. A worktree is a working directory with a checkout of one. Every worktree has a branch or a detached commit in it, so they are complementary rather than alternatives.

The question does not resolve that way. You always use branches. The choice is whether to switch between them inside one directory or to check several out at once in separate worktrees.

When the work is genuinely concurrent: a long test run you do not want to block on, a review you need to do without stashing, comparing two branches side by side, or more than one agent working at the same time.

For concurrent work, yes. The checkout is cheap because the object database is shared. The real cost is per-worktree dependency directories, which a content-addressed package manager such as pnpm reduces to hard links.

Yes, with --detach, which checks out a commit directly. It is the right form for reading a tag, reviewing an old release, or bisecting without disturbing the branch you are working on.

For the common case of "I need to look at something else right now", largely yes, and more safely. A worktree leaves your work untouched in its own directory instead of putting it on a stack you might forget. Note that the stash itself is shared across every worktree in a repository.

Yes, or a detached HEAD. Git refuses to check out the same branch in two worktrees, because two directories committing to one ref diverge as soon as either commits.

Three is comfortable and five is a lot. Past that the directories stop being an index of what you are doing and become something you have to maintain, and with agents involved the binding limit becomes how much diff you can actually review.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. git-worktree manual
  2. Pro Git book
Try it

Concurrency,
made safe.

Continuum gives every agent session its own worktree and branch, so two agents can never collide.

free app · your subscriptions · local-first