Skip to content

Unable to use git even with workspace-write #5034

Closed

Description

@gcp

What version of Codex is running?

codex-cli 0.46.0

Which model were you using?

gpt-5-codex

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

codex -s workspace-write

› Move the last 2 commits to a branch called "codex-rackleave".

• Explored
  └ List heads

• Ran git branch --show-current
  └ master

• Ran git checkout codex-rackleave
  └ failed in sandbox: fatal: Unable to create '/Users/morbo/git/scrax/.git/index.lock': Operation not permitted

• I'm exploring why git can't create the index.lock file, likely due to system-level restrictions such as immutable flags or
  extended attributes on the .git directory or its files, which blocks changing branches or modifying the index. I'll check
  further with xattr -l .git to see if any attributes prevent write operations despite chmod changes.

And so on, while the model tries to debug why it can't write things.

What is the expected behavior?

Writing to .git should work.

What do you see instead?

No response

Additional information

No response

Activity

  1. added
    bug
    on Oct 10, 2025
  2. added
    CLI
    on Oct 10, 2025
  3. chall37 commented on Oct 10, 2025

    @chall37

    This is probably functioning as intended, see:

    80555d4

    I suspect this decision was made because agents have been known to inadvertently blow away entire projects, and we probably don't want them to take the .git folder with it.

  4. nornagon-openai commented on Oct 10, 2025

    @nornagon-openai
    Contributor

    @chall37 is correct. Eventually we will have more fine-grained control over the sandbox, but for now if you want write access to .git you'll need to pass --dangerously-bypass-approvals-and-sandbox.

  5. gcp commented on Oct 10, 2025

    @gcp
    Author

    With the competition (ahem) this would generate a request for approval to the user, who can then sanity check the git command.

  6. fortuna commented on Nov 3, 2025

    @fortuna

    I was able to fix this problem by telling codex to escalate any write operations on Git. That disables the sandbox protection and allows the commits to go through.

    Codex should add that to their system prompt.

  7. dmahurin commented on Nov 13, 2025

    @dmahurin

    @nornagon-openai and others,

    Instead of elevating permissions, we can create a separate shadow git directory for codex to commit changes to.

    Here is a script that allows this.

    https://github.com/dmahurin/git-shadow/blob/main/mk-git-shadow

    This script creates a new git-dir using object alternates to inherit form the existing .git and a worktree which points back to the current directory.

    Use:
    mk-git-shadow .aigit

    GIT_DIR=pwd/.aigit npx @openai/codex ...

    Then review and pull:
    git --git-dir .aigit log
    git pull .aigit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions