Codex adds a .git folder to my source control branch that breaks TFVC.
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_patch call.
- 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, or apply_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 nested apply_patch.
- Add a Windows regression test for editing a file in a non-Git directory
and verifying that .git remains 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.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
If you think this is a duplicate, FIX IT!!!!!!!!!!! This is not acceptable!