Git Worktree
An additional working directory attached to one repository, each on its own branch.
A git worktree is a second (or tenth) working directory backed by the same repository, each checked out to a different branch. It removes the need to stash and switch: several branches can be open, built, and running at once.
It is the standard answer to parallel work, and especially to several agents or processes working simultaneously — each gets a real directory that nobody else writes to. See Multi-Agent Orchestration.
The complications are all about the things a worktree does not isolate.
Untracked files do not come along. Environment files, local configuration, and installed dependencies must be provisioned per worktree, and a worktree missing them fails in ways that look like code defects — tests asserting a port that differs, a service tier that differs, an empty credential.
Ports and containers collide. A per-worktree port derived from the directory name is not collision-free, and a command that reads its port from the shell rather than the local environment file will happily bind the primary checkout's port — at which point someone else's browser is talking to your code and writing to your database.
Shared repository state is still shared. The object store, the recorded conflict resolutions, and anything in the common git directory are common to all worktrees.
See also5
Hand-picked in the note itself — the neighbours worth reading next.
Version Control
A system recording the history of a project's files, enabling branching, merging, and recovery.
Version Control & Delivery13 connections
Race Condition
A defect whose occurrence depends on the relative timing of concurrent operations.
Testing & Verification11 connections
Environment Variable
A named value in a process's environment, inherited by its children — the standard configuration channel.
Systems & Tooling14 connections
Port
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
Systems & Tooling8 connections
Subagent
A model instance spawned by another to handle a scoped task with its own context.
Agents & Language Models11 connections
Related3
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from7
Notes elsewhere in the wiki that reach for this one.
- ContainerizationSystems & Tooling
Packaging an application with its dependencies into an isolated, reproducible runtime unit.
- Fan-Out and Fan-InAgents & Language Models
Splitting work across parallel workers and recombining their results.
- Multi-Agent OrchestrationAgents & Language Models
Coordinating several model instances on one body of work, each with its own context.
- PortSystems & Tooling
The numeric endpoint a network service listens on, and a scarce shared resource on a developer machine.
- Race ConditionTesting & Verification
A defect whose occurrence depends on the relative timing of concurrent operations.
- SubagentAgents & Language Models
A model instance spawned by another to handle a scoped task with its own context.
- Version ControlVersion Control & Delivery
A system recording the history of a project's files, enabling branching, merging, and recovery.