Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

What Git Worktrees Share—and What Parallel Agents Keep Separate

Git worktrees isolate checked-out files, HEAD, and the index, but share most refs and repository configuration by default. Learn what that means for parallel agent sessions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Git worktrees share a repository, but not every part of a checkout. Each worktree has its own checked-out files, HEAD, and index; most refs and repository configuration are shared by default. That separation lets parallel tasks work on different branches, but it does not guarantee that an AI tool’s sessions, settings, or sandbox are isolated.

Which Git state is shared between worktrees?

Git describes git worktree as a way to “Manage multiple working trees attached to the same repository.” The main worktree is the original checkout; additional checkouts are linked worktrees. They have separate working directories and per-worktree administrative state, while sharing much of the repository’s data. See the Git worktree documentation.

As an Amazon Associate I earn from qualifying purchases.

State Default behavior What that means
Checked-out files Separate by worktree Edits in one working directory do not automatically change the other worktree’s files.
HEAD and index Per-worktree Each tree can have its own current commit or branch and its own staging area.
Most refs, including ordinary branch refs Shared Branches and other shared references are repository-level state, not private copies per directory.
Exceptions to shared refs Per-worktree exceptions include refs/bisect, refs/worktree, and refs/rewritten Git documents these exceptions; do not assume every ref is shared or every ref is private.
Repository configuration Shared by default A setting changed in shared config can affect use from other worktrees.

The repository’s object database is shared as well, so linked worktrees are not separate repository copies. Git’s repository layout documentation explains the common directory and per-worktree files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why separate directories do not mean separate Git metadata

A linked worktree has a private administrative directory under the repository’s worktrees directory. Its top-level .git is a file pointing to that private administration; a common directory holds shared repository data. Consequently, HEAD and a branch ref can resolve from different administrative locations.

For example, in a linked worktree, git rev-parse --git-path HEAD identifies that worktree’s private HEAD, while git rev-parse --git-path refs/heads/<branch> resolves through the common directory for an ordinary branch ref. Scripts should ask Git to resolve these paths instead of assuming a fixed layout or hard-coding $GIT_DIR or $GIT_COMMON_DIR.

How to organize parallel tasks safely

  1. Create one worktree and branch per concurrent task. Git normally prevents checking out the same branch in multiple worktrees. Keep that safeguard; using --force to bypass it is not a routine way to coordinate concurrent work. Consult the worktree command documentation for the command options.
  2. Inspect worktrees with Git. Use git worktree list for a human-readable inventory, or git worktree list --porcelain when a script needs stable, machine-readable output.
  3. Keep scripts independent of Git’s internal layout. Use git rev-parse --git-path <path> to find administrative paths. Change refs and configuration through commands such as git update-ref and git config, rather than editing internal files directly.
  4. Decide whether configuration should be shared. Shared repository configuration is the default. To use worktree-specific settings, enable the extensions.worktreeConfig extension and use git config --worktree. Check the compatibility and migration guidance in the Git documentation before adopting it, especially if the repository is used with older Git versions.
  5. Use Git’s commands when moving or cleaning up worktrees. Prefer git worktree move for a managed move and git worktree repair if the association needs repair. Use git worktree remove for ordinary removal. If you deleted a directory manually and stale administration remains, run git worktree prune.
  6. Lock trees on storage that may be unavailable. If a worktree is on intermittently mounted storage, git worktree lock protects its administration from pruning while the directory is unavailable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What a worktree does—and does not—guarantee for agent sessions

Git’s worktree model describes Git files and repository metadata. It does not define how a particular agent application stores session records, chooses a project configuration file, or applies sandbox boundaries. A separate worktree therefore provides useful checkout and index separation, but it is not proof of application-level isolation.

Public Codex CLI issue reports illustrate why the distinction matters, but they are reports of particular cases, not general product guarantees. One open report describes a user whose new worktree session was interrupted while another session was active in the base worktree; the user also said a later launch read a project hooks configuration path from the base worktree. The report does not establish a confirmed root cause, universal behavior, or current fix status: Codex CLI issue report.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A separate report describes Codex CLI 0.158.0 on macOS in a particular workspace-write layout: the linked worktree’s private administration was protected while its shared common directory remained writable. The concern in that report was that shared hooks or configuration could affect later Git use. This is specific to the reported version, platform, and layout; it should not be generalized to other configurations: Codex CLI issue report.

For parallel agent work, treat Git separation and application isolation as separate checks. Confirm which worktree and branch each process uses, and inspect the tool’s own session, project-configuration, and sandbox behavior rather than inferring it from directory separation alone.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.