worktree
in English: git worktree
A worktree is an additional working instance of the same codebase opened in a separate folder, allowing multiple tasks to be worked on simultaneously without them mixing.
In plain terms
Imagine working on a thick manuscript and needing to rewrite two chapters at once. If you have only one desk, you must pack away the pages of one chapter every time you switch to get the other. A worktree is like getting a second desk: both chapters can remain open, yet the manuscript is still just one.
Programmers use the Git version control system to track code changes. Typically, one working directory belongs to a project, and only one version (branch) can be active at a time. With worktree, you can open multiple directories for the same project, each with a different branch.
In the AI era, it suddenly became important because often multiple coding agents work on the same project simultaneously. If three agents were rewriting files in the same folder, they would ruin each other's work. If each gets its own worktree, they can work peacefully, and the final result can be merged at the end.
How it works
- The project has a shared repository (repo) that preserves the entire history of the code; there is always only one.
- With one command (git worktree add), you request a new folder and specify which branch it should contain. Git places the appropriate version of the files there.
- In the new folder, you can edit, test, and save just as in the original. Changes made here do not appear in other folders.
- Saves (commits) go into the shared repository, so the history is not copied multiple times, and folders can be aware of each other's branches.
- Once the task is done, you merge the branch into the main version and delete the now-unnecessary worktree.
An everyday example
You ask a coding agent to build a new feature for your webshop while another agent fixes an urgent bug. Both work in separate worktrees, so they do not overwrite each other's files, and you review and accept their work individually at the end.
Who is affected
A common misconception
Limits and risks
- The same branch cannot normally be open in two worktrees simultaneously, so every parallel task needs its own branch.
- It only separates the files: the database, network ports, and external services remain shared, so agents can still interfere with each other there.
- Files excluded from version control (such as settings containing passwords or installed packages) are not transferred to the new folder and must be configured separately there.
- It does not eliminate conflicts, only postpones them: if two agents changed the same section of code, someone has to decide at merge time.
Similar, but not the same
- branch – A branch is the name of a version of the code in the history, while the worktree is the folder where the files of such a version are actually laid out.
- cloning (git clone) – A clone is a full independent copy of a repository with its own history, while a worktree is an additional working directory built on the same shared repository.
- sandbox – The sandbox is a security isolation that restricts what a program can access, while the worktree only organizes files into a separate folder, providing no protection.
Related concepts
A brief history
Linus Torvalds launched the Git version control system in 2005. The worktree command was added with version 2.5 released in 2015 and remained a little-known advanced feature for many years until coding agents working in parallel made it widely known.
Where things stand
As of late 2026, worktrees are a long-stable, built-in part of Git, and several AI coding tools automatically create one for their agents. Among developers, it is one of the usual ways to run agents in parallel.
In the news
- GitHub open-sources Replica prototyping tool; JetBrains shows ThinkRail IDEOct 28, 2026 · Code
Also known as
worktree · git worktree · work tree · working tree · linked worktree · munkafa · Git-munkafa
Sources
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.