Skipping the git repository check in Codex allows commands to run in temporary directories or non-versioned projects without creating a repository first.
The --skip-git-repo-check flag disables the guard that normally requires a repository root before execution. The flag applies only to the current command invocation and does not change global configuration.
Running outside a repository removes version-control context such as diffs, history, and branch state. For work that needs review or rollback, initializing a repository or running from inside an existing working tree keeps the usual safeguards.
Related: How to set Codex working directory
Related: How to enable JSON output in Codex exec
Steps to skip Codex git repository checks:
- Create a scratch directory for non-repo runs.
$ mkdir -p /tmp/codex-scratch
- Change to the directory that should run without git context.
$ cd /tmp/codex-scratch $ pwd /tmp/codex-scratch
- Confirm the current directory is not a git working tree.
$ git rev-parse --is-inside-work-tree fatal: not a git repository (or any of the parent directories): .git
The fatal message indicates the repository guard would trigger in this directory.
- Run Codex with --skip-git-repo-check to bypass the repository guard.
$ codex exec --skip-git-repo-check "Return OK." OK.
Changes produced outside git are not tracked automatically, which can make review and rollback harder.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
