git push --set-upstream fails writing .git/config despite .git being in the write allowlist

Status Open
Maintainer reply None cached
Activity 0 comments · opened Sep 10, 2026

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

  1. In a Claude Code session with the Bash sandbox enabled (default), in a repo where .git is within the write allowlist.
  2. Run git push --set-upstream origin <some-branch>.
  3. The push to the remote succeeds, but the local tracking-branch config write fails with the error above.
  4. 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.

View original on GitHub ↗