How to skip Codex git repository checks

Scratch-folder Codex runs can fail before the prompt starts when codex exec is launched outside a Git working tree. The repository check protects normal project work, but an intentional temporary directory may need a one-run override instead of a repository checkout.

The --skip-git-repo-check flag bypasses only the non-interactive repository guard for that command. It does not authenticate the CLI, widen the sandbox, or mark a directory as trusted for project-scoped .codex/config.toml layers.

Use the flag only after the working directory is known and isolated. A safer fix for normal project work is to move into the intended repository, because the same prompt can otherwise read or write files from a scratch path that was not meant to own the task.

Steps to skip Codex git repository checks:

  1. Confirm the scratch directory is outside a Git working tree.
    $ git rev-parse --show-toplevel
    fatal: not a git repository (or any of the parent directories): .git

    If this command prints a repository path, keep the repository check enabled and run Codex from that project instead.

  2. Reproduce the repository safeguard before using the override.
    $ codex exec --ephemeral --sandbox read-only "Return OK."
    Not inside a trusted directory and --skip-git-repo-check was not specified.

    The message appears before a model run starts, so it is separate from authentication, sandbox, and prompt errors.

  3. Re-run the same prompt with --skip-git-repo-check from an authenticated CLI.
    $ codex exec --ephemeral --sandbox read-only --skip-git-repo-check "Return OK."
    OK

    Use the override only for a directory created for the task. It removes the repository boundary that normally catches a command launched from the wrong folder.

  4. Check the working directory when the prompt needs to prove where it ran.
    $ codex exec --ephemeral --sandbox read-only --skip-git-repo-check "Run pwd and return only the command output."
    /home/user/tmp/codex-scratch

    The printed path should match the scratch directory that was intentionally selected. Use -C when a script launches Codex from another shell location.