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

Open
#34,799 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
desktop, tooling

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

app bug hooks tool-calls windows-os
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.
  6. 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.
  2. Add a supported global setting equivalent to:
    never create or initialize Git metadata.
  3. Make that setting independent of AGENTS.md and model compliance.
  4. Ensure policy hooks cover code-mode exec calls and nested tool calls,
    including nested apply_patch.
  5. 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.

Dominant language
Rust
Stars
125k
Forks
19.5k
Avg merge
1m
Merged PRs (30d)
1k

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.