Codex adds a .git folder to my source control branch that breaks TFVC.

Open 💬 2 comments Opened Jul 22, 2026 by joe-miles
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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

  1. Create or open a directory that is not a Git repository.
  2. Verify <workspace>\.git does not exist.
  3. Open the directory in Codex Desktop.
  4. Ask Codex to make an ordinary source-file modification.
  5. Codex performs an exec operation containing a nested

tools.apply_patch call.

  1. Observe that <workspace>\.git has 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 exec containing tools.apply_patch.
  • 11:12:14 AM: <workspace>\.git was 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

  1. Stop creating .git as a side effect of file editing, sandbox setup,

workspace detection, checkpointing, or apply_patch.

  1. Add a supported global setting equivalent to:

never create or initialize Git metadata.

  1. Make that setting independent of AGENTS.md and model compliance.
  2. Ensure policy hooks cover code-mode exec calls and nested tool calls,

including nested apply_patch.

  1. 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.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 1 month ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #34672
  • #33813

Powered by Codex Action

joe-miles · 1 month ago

If you think this is a duplicate, FIX IT!!!!!!!!!!! This is not acceptable!