Codex adds a .git folder to my source control branch that breaks TFVC.
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
Research direction
Start by tracing Codex Desktop's exec and nested tools.apply_patch flow, along with workspace detection, sandbox setup, checkpointing, and policy-hook handling. Reproduce the edit on Windows in a non-Git directory and identify which path creates .git. Done means ordinary edits leave .git absent, the global prohibition is enforced independently of AGENTS.md, nested calls are covered, and a Windows regression test verifies this.
Written by the indexing model from the issue text.
Description
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.715.21425
What subscription do you have?
Enterprise? I don't know. I have it through work. I have unlimited access.
What platform is your computer?
Windows 11 Enterprise 10.0.26200, x64
What issue are you seeing?
Problem
Codex Desktop silently creates an empty .git directory at the root of a
non-Git workspace while performing an ordinary source-code edit.
The user did not request Git initialization. An AGENTS.md instruction
explicitly prohibits creating or initializing Git metadata.
A global PreToolUse hook intended to block Git-related filesystem changes
was also enabled, but it did not prevent the directory from being created.
What steps can reproduce the bug?
Reproduction
- Create or open a directory that is not a Git repository.
- Verify
<workspace>\.gitdoes not exist. - Open the directory in Codex Desktop.
- Ask Codex to make an ordinary source-file modification.
- Codex performs an
execoperation containing a nested
tools.apply_patchcall. - Observe that
<workspace>\.githas been created.
The resulting .git directory is empty.
Evidence
Observed on July 22, 2026, in the America/Denver time zone:
- 11:12:13 AM: Codex invoked
execcontainingtools.apply_patch. - 11:12:14 AM:
<workspace>\.gitwas created. - The created directory contained zero entries.
- No Git operation was requested or authorized.
Paths and usernames have been replaced with generic placeholders.
Actual behavior
Codex modifies the workspace by creating an empty .git directory. This can
change source-control and repository detection even though the directory is
not a valid initialized Git repository.
What is the expected behavior?
Expected behavior
Codex must not create .git, initialize Git, or create placeholder Git
metadata unless the user explicitly requests it.
Ordinary file-editing capabilities must work in TFVC, SVN, Perforce, and
unversioned directories without creating Git artifacts.
Additional information
Requested fixes
- Stop creating
.gitas a side effect of file editing, sandbox setup,
workspace detection, checkpointing, orapply_patch. - Add a supported global setting equivalent to:
never create or initialize Git metadata. - Make that setting independent of
AGENTS.mdand model compliance. - Ensure policy hooks cover code-mode
execcalls and nested tool calls,
including nestedapply_patch. - Add a Windows regression test for editing a file in a non-Git directory
and verifying that.gitremains absent.
Impact
This repeatedly modifies non-Git codebases without authorization and forces
users to choose between allowing Codex to edit files and preserving the
workspace's source-control state.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·