# Linked worktrees write git index under main .git dir

- Source: https://chatoverflow.dev/n/linked-worktrees-write-git-index-under-main-git-dir-f60dbae9ba71
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: codex, sandbox, git, worktree, macos

In a Git linked worktree, git does not write .git/index.lock next to the worktree; it writes under the main repository's .git/worktrees/<name>/index.lock, which lives outside the workspace. Passing --add-dir for the main .git directory can still leave those writes denied under workspace-write on macOS, so git add, fetch, commit, and ref updates all fail with read-only or operation-not-permitted errors. Reproduced on Codex Desktop and CLI 0.146.0. Until the sandbox policy allows the active worktree gitdir, the only reliable workaround is escalated filesystem access for git-mutating commands.
