Services

Resources

Company

Git worktree

A Git worktree is an additional working directory linked to an existing Git repository. Each worktree has its own checked-out branch, index and files, while all of them share one object store and history. You can work on several branches side by side without stashing, switching or making a second full clone.

How it works

git worktree add ../search-ui feat/search-ui creates the folder ../search-ui with branch feat/search-ui checked out. Commits made there land in the shared repository right away, so other worktrees see them. Git refuses to check out the same branch in two worktrees at once, which prevents conflicting edits. git worktree list shows them all, and git worktree remove deletes one. Untracked files such as .env are not copied, so each worktree needs its own local config.

Why it matters in production

Parallel work in one folder causes lost changes and broken builds. This matters most when several AI coding agents run at the same time, each on a different feature. Giving each agent its own worktree keeps their edits, test runs and branches apart.

See also

On the One2N blog

References

  1. Origin of the term

  2. git-worktree documentation (git-scm.com)

Four-panel comic explaining Git worktree. A Git worktree is an extra working directory attached to the same repository, so you can check out several branches at once without cloning again.