Git worktree vs branch: what's the difference and when to use each

A branch is a line of commits; a worktree is a folder where a branch is checked out. When to switch branches, when to add a worktree, and how stash and clone compare.

Short answer: a branch is a movable name for a line of commits. A worktree is a directory on disk where one branch is checked out. They aren’t alternatives: every worktree has a branch (or a detached HEAD) checked out. The real choice is between switching branches in one folder and giving each branch its own folder.

What a branch is

A branch is a pointer, a file in .git/refs/heads/ holding one commit ID, that moves forward when you commit. Creating one costs nothing and changes no files. In a normal clone you see one branch at a time: git switch rewrites the files in your folder to match the branch you switch to.

What a worktree is

A worktree is an extra working directory attached to the same repository. It has its own files, its own index and its own HEAD, but shares commits, branches and config with the main checkout. With worktrees you can have several branches checked out at once, each in its own folder.

Side by side

Switch branchesOne worktree per branch
Folders on diskOneOne per branch
Branches open at onceOneMany
Uncommitted work when switchingMust commit or stash firstStays put in its folder
Dependencies and build cacheRebuilt after many switchesInstalled once per folder
Disk useLowestExtra checked-out files, plus each folder’s dependencies
Same branch in two placesn/aNot allowed
Good forShort, sequential tasksParallel work, long builds, AI agents

When switching branches is enough

  • You work on one thing at a time and finish it before starting another.
  • The project builds fast and has no heavy per-branch dependencies.
  • You rarely have uncommitted work when you need to switch.

When a worktree is better

  • Interruptions. A hotfix comes in while you’re mid-feature. Open a worktree on main instead of stashing half-done work.
  • Reviewing a pull request while your own branch keeps its state, running dev server included.
  • Long-running jobs. A test suite or build runs in one folder while you keep coding in another.
  • AI coding agents. Claude Code, Codex and others edit files directly, so each needs its own folder. See running agents in parallel and claude --worktree.

What about stash and clone?

Stash parks uncommitted changes so you can switch branches in the same folder. It works for a quick detour, but stashes are easy to forget, and they are shared by every worktree of a repository. A second clone gives you another folder too, but with a separate copy of the history. You have to fetch and push between clones, and branches in one clone aren’t visible in the other. A worktree gives you the separate folder without the separate repository.

The catch with worktrees

Folders are easy to make and easy to forget. A month in, you might have a dozen worktrees: some merged, some with commits that only exist on your laptop, some with changes nobody committed. Orchard shows every worktree on your Mac in one view and says which ones still hold work and which ones are already in main. Cleaning up by hand? Use our cleanup checklist.

FAQ

Is a git worktree the same as a branch?

No. A branch is a named pointer to commits. A worktree is a folder where a branch is checked out. You can have many branches with only one worktree, but each extra worktree needs its own branch or a detached HEAD.

Can two worktrees have the same branch checked out?

No. git allows a branch to be checked out in only one worktree at a time, and reports that the branch is already used by another worktree. Use a separate branch, or a detached HEAD for read-only work.

Should I use git worktree or git stash?

Use stash for a quick detour of a few minutes in the same folder. Use a worktree when the other task will take longer, needs a build or dev server of its own, or is being done by an AI agent at the same time.