git push --set-upstream fails writing .git/config despite .git being in the write allowlist
Summary
git push --set-upstream origin <branch> completes the push itself, but fails setting the local tracking ref: error: could not lock config file .../.git/config: Operation not permitted — despite .git being covered by the sandbox's write allowlist for the current project.
Likely cause
Git writes its config via a lockfile create-then-rename (write .git/config.lock, then rename over .git/config), rather than an in-place write. That specific pattern doesn't appear to be covered by the same allowance as a direct write to a path under .git.
Reproduction
- In a Claude Code session with the Bash sandbox enabled (default), in a repo where
.gitis within the write allowlist. - Run
git push --set-upstream origin <some-branch>. - The push to the remote succeeds, but the local tracking-branch config write fails with the error above.
- The identical command succeeds fully with
dangerouslyDisableSandbox: true.
Suggested fix
Confirm whether the write-allowlist logic covers lockfile create+rename against an allowlisted path, not just a direct open-and-write — this looks like a gap in what "allowlisted" actually protects against, rather than an intentional restriction.