Skip to content

Git worktree

Also called Worktree

What is Git worktree?

A Git worktree is an extra working directory attached to the same repository, so you can have several branches checked out at once in separate folders without stashing or re-cloning.

A feature allowing you to have multiple working directories attached to a single Git repository, meaning you can check out multiple branches simultaneously.

A worktree lets you clone a repository once, but open several different branches in entirely separate folders on your computer. This isolates your environments so you can run a heavy local server on one branch while writing code in another without constantly stashing and switching context.

How it relates to Orbit

A sandboxed Orbit prompt runs in its own Git worktree so its changes can be reviewed before promotion. See Sandbox for details.

When you would use it

You use worktrees when you need to frequently jump between two drastically different branches and the cost of switching (like rebuilding dependencies or restarting servers) is too high.

Common operations

  • Running a long test suite on one branch while coding on another.
  • Keeping a stable production branch running in one folder while actively developing a feature branch in another.

Frequently asked questions

How do you create a Git worktree?

Run git worktree add <path> <branch>. The new folder shares the repository’s history, and git worktree remove deletes it when you are done.

What is the difference between a worktree and a clone?

A clone copies the whole repository again. A worktree shares one repository and its objects, so it is quicker to create and every commit is visible from both folders.

Why do coding agents use worktrees?

So parallel runs never share a working copy. Orbit runs sandbox sessions, Coordinator subtasks and Benchmark runs each in their own worktree. See Sandbox.

Related terms

Where this is taught

No learning path uses this term yet. Browse the Learning Atlas for guided sequences through related ideas.