Codex Desktop Creates Empty `.git` Directories, Then Repeatedly Scans Them and Triggers Windows Defender High CPU
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.616.81150
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Windows 10
What issue are you seeing?
Codex Desktop on Windows appears to create empty folders named .agents, .codex, and .git inside project directories. The empty .git directories are then picked up by Codex Desktop's own background Git origin scanner, which repeatedly launches Git for Windows to run git config --get remote.origin.url. This causes a continuous git.exe / conhost.exe process loop and triggers Microsoft Defender real-time scanning, resulting in sustained high CPU and high power usage.
Deleting the empty .git directories immediately stops the git.exe loop and reduces Defender CPU usage back to low levels without restarting Codex.
What steps can reproduce the bug?
Once empty .git directories exist, Codex Desktop's background git-origins scanner repeatedly launches Git for Windows.
- Microsoft Defender process
Antimalware Service Executablerises to around 20% CPU. - Windows Task Manager shows high or very high power usage.
Git for WindowsandConsole Window Hostrepeatedly appear and disappear.- Codex may be idle, but the process churn continues.
- Removing the empty hidden directories causes Defender CPU to drop below 2% and stops the
git.exeloop.
Evidence from Codex Logs
Codex logs repeatedly show Git origin scanning:
requestKind=git-origins
source=sidebar_workspace_task_groups_task_dirs
What is the expected behavior?
Codex Desktop should not create an empty .git directory unless it is initializing a real Git repository.
If Codex creates placeholder directories, its own Git scanner should ignore empty .git directories that are not valid Git repositories.
Codex should not repeatedly launch Git in the background for directories that have no remote origin and no real Git metadata.
Additional information
The Project feature is a helpful way to separate different topics and workflows. However, Codex should not automatically create empty .git, .agents, or .codex directories as placeholders, especially for projects used in “for everyday work” mode.
9 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thanks for writing this up. I am seeing a related Windows Codex Desktop performance regression in #28855: since June 12, opening/using Codex Desktop can cause severe intermittent mouse/typing/system input lag, and it still persists for me on
OpenAI.Codex 26.616.10790.0.I linked your report in a broader Discussion collecting recent Windows Desktop performance reports here: https://github.com/openai/codex/discussions/29949#discussioncomment-17428007
No action needed from you unless you want to add more detail there, but I wanted to connect the reports because the recent Windows issues look related enough that they may need a canonical tracker.
I have the same issue, my Windows Desktop Codex creates a .git folder inside of my project folder(1 level below the project folder with original .git) and bugs my IDE. I need to delete to solve.
I can confirm this is still reproducible for me on the current Windows Codex app, and I have before/after process evidence that an empty/non-repository
.gitdirectory is enough to trigger repeated Git child-process spawning.Environment:
OpenAI.Codex 26.623.5546.010.0.26200, 64-bitgit version 2.54.0.windows.126416Trigger condition:
.gitdirectory, but it is not a valid Git repo..gitdirectory was empty: recursive item count0, no.git/HEAD.git -C <project> rev-parse --git-dir --git-common-dir --is-inside-work-tree --show-toplevelreturns:Observed current behavior:
.gitdirectory present, a 30-second process monitor captured138Git processes,94of them direct children of the Codex main process.56x"C:\Program Files\Git\cmd\git.exe" -c core.hooksPath=NUL -c core.fsmonitor= rev-parse --show-toplevel6x"C:\Program Files\Git\cmd\git.exe" config --null --get core.fsmonitor32direct children where command line was gone before it could be read51x the affected project directory43x blank/unreadable current directoryMitigation/control:
.gitdirectory aside, without restarting Codex.0Git processes..git: 60-second monitor captured128Git processes,95direct children..git: 60-second and 120-second monitors both captured0Git processes.Impact:
.gitdirectory is recreated; I saw it recur today after having mitigated it yesterday.Likely product-side fix:
.gitexistence as only a hint, not proof of a valid Git repository.rev-parse --show-toplevelreturns "not a git repository" for a directory whose.gitpath exists but is invalid/empty, do not immediately re-arm a watcher that synchronously re-triggers on the same invalid.gitdirectory..gitdirectories, or require a real Git marker such as.git/HEAD/ valid gitfile contents before firing the "git initialized" path.I have local CSV/JSON captures and stack samples if maintainers want them, but I did not attach raw logs here because they contain local paths/session context.
Follow-up / correction to my earlier follow-up: I want to narrow this to the part I can actually support.
After mitigating the repeated Git-spawning issue by renaming/removing an empty invalid
.git, I noticed that the affected workspace was an old Codex workspace path whose real work had since been moved elsewhere. I had deliberately left a local pointer file in the old directory when I moved the work, so that file name is not itself a Codex artifact or meaningful product signal. It is just how I marked my own move. If I had deleted the old workspace entirely, this variant may not have appeared.The relevant pattern is:
.gitmay appear or reappear there.git.exework as described in my previous comment.I am intentionally omitting exact local path names and my own cleanup/workaround artifacts here; those are not product signals.
The product-side checks that still seem useful:
.gitexistence alone as proof of a valid repository; require a valid.git/HEAD, a valid gitfile, or a successfulrev-parse;.gitdirectories and non-git workspaces with backoff;This may still relate to the other reports about stale project state and empty
.gitcreation, but the actionable signal from my side is narrower: stale workspace path + invalid empty.git+ repeated Git probing.I can confirm this pattern on Windows with Codex package
OpenAI.Codex_26.623.11225.0.A current Codex chat workspace contained an empty/invalid
.gitdirectory:The directory was empty and had no
HEAD, noconfig, and noobjects.While Codex was idle, ETW showed repeated child processes from
Codex.exe:Before removing the empty
.gitdirectory, a 120s sample saw:git.exeprocessesconhost.exeprocessesMsMpEng.exeat ~55.6% of one CPU coreAfter deleting only that empty
.gitdirectory, a 60s sample saw:git.exeprocessesconhost.exeprocessesMsMpEng.exeat ~1.1% of one CPU coreSo in this case Microsoft Defender was not the root cause. It was amplifying Codex's repeated Git probing against an invalid empty
.gitdirectory.One extra detail: this was not a real user Git repository. It was the current default Codex workspace/chat folder under
%USERPROFILE%\Documents\Codex\..., and the invalid.gitdirectory was empty.Follow-up: I prepared a candidate fix in a fork, but I cannot open a PR because this repository currently restricts PR creation to collaborators.
Branch: https://github.com/crash2kx/codex/tree/codex/ignore-invalid-dot-git
Commit: https://github.com/crash2kx/codex/commit/ad2446498983a574b728599d01c0b5ba02fdb28c
Compare: https://github.com/openai/codex/compare/main...crash2kx:codex/ignore-invalid-dot-git
The patch changes lightweight Git root discovery so an empty
.gitdirectory is not treated as a valid repository marker..gitdirectories now need the minimal structure Git itself accepts (HEAD,objects/,refs/), while.gitpointer files usinggitdir:remain supported. I also added regression coverage for empty.gitdirectories.Local validation performed:
git diff --checkgit rev-parse --is-inside-work-treeprobe confirmedHEAD + objects + refsis accepted by Git while empty/HEAD-only.gitdirectories are rejected.cargo testwas not run locally because the Windows host used for this fix does not have a Rust toolchain installed and WSL is not installed.Another confirmed Windows data point for the invalid/empty
.gittrigger, with one additional mitigation detail.In my case the high idle CPU/power issue remained after several Codex updates and initially looked like generic desktop idle load. Further tracing showed Codex repeatedly launching this command family from a persisted workspace path:
The affected workspace path contained an empty/invalid
.gitdirectory. I am intentionally omitting the real local path and any user-specific names here.What finally fixed it locally:
.gitdirectory..gitis enough.and put this in
.git/info/exclude:Verification after fixing the invalid
.git:git.exeprobes stopped (git_count=0during follow-up sampling);So this matches the product-side diagnosis already discussed here: Codex should not treat
.gitexistence alone as a valid repository signal. A valid.git/HEAD/ gitfile / successfulrev-parsecheck, plus negative caching/backoff for invalid.gitdirectories, would likely prevent this loop.I published a conservative temporary Windows workaround for the empty/invalid .git trigger discussed here:
https://github.com/Snowsword168/CodexGitGuard
It is event-driven, removes only persistently empty child .git directories, preserves non-empty repositories and worktree pointer files, and does not terminate processes. It is not an official OpenAI fix and is intended only as a mitigation until the underlying repository-detection loop is fixed.