You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex Desktop Creates Empty .git Directories, Then Repeatedly Scans Them and Triggers Windows Defender High CPU #29911
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 Executable rises to around 20% CPU.
Windows Task Manager shows high or very high power usage.
Git for Windows and Console Window Host repeatedly 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.exe loop.
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.
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: #29949 (comment)
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 .git directory is enough to trigger repeated Git child-process spawning.
Environment:
Codex Windows app package: OpenAI.Codex 26.623.5546.0
OS: Windows 11 Pro 10.0.26200, 64-bit
Git: git version 2.54.0.windows.1
Codex main process in the fresh capture: PID 26416
Trigger condition:
Project directory contains a .git directory, but it is not a valid Git repo.
The .git directory was empty: recursive item count 0, no .git/HEAD.
fatal: not a git repository (or any of the parent directories): .git
Observed current behavior:
With the empty .git directory present, a 30-second process monitor captured 138 Git processes, 94 of them direct children of the Codex main process.
Direct child command counts included:
56 x "C:\Program Files\Git\cmd\git.exe" -c core.hooksPath=NUL -c core.fsmonitor= rev-parse --show-toplevel
6 x "C:\Program Files\Git\cmd\git.exe" config --null --get core.fsmonitor
32 direct children where command line was gone before it could be read
Direct child working-directory counts included:
51 x the affected project directory
43 x blank/unreadable current directory
Mitigation/control:
I renamed the empty .git directory aside, without restarting Codex.
An immediate follow-up 30-second monitor captured 0 Git processes.
The same pattern was captured yesterday on an earlier Codex main process:
Before renaming empty .git: 60-second monitor captured 128 Git processes, 95 direct children.
After renaming empty .git: 60-second and 120-second monitors both captured 0 Git processes.
Impact:
On this workstation the repeated Git process spawning correlated with a sustained hot Codex/libuv thread, background CPU load, fan spin-up, and thermal pressure.
The symptom can reappear if the empty .git directory is recreated; I saw it recur today after having mitigated it yesterday.
Likely product-side fix:
Treat .git existence as only a hint, not proof of a valid Git repository.
If rev-parse --show-toplevel returns "not a git repository" for a directory whose .git path exists but is invalid/empty, do not immediately re-arm a watcher that synchronously re-triggers on the same invalid .git directory.
Add a negative cache/backoff for invalid .git directories, 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:
A Codex project/thread can remain associated with an old workspace path.
The real active work is moved elsewhere.
The old path remains as a non-git placeholder directory.
An empty/invalid .git may appear or reappear there.
Git metadata discovery then repeatedly probes that stale invalid repo path, causing repeated git.exe work 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:
do not treat .git existence alone as proof of a valid repository; require a valid .git/HEAD, a valid gitfile, or a successful rev-parse;
negative-cache invalid .git directories and non-git workspaces with backoff;
if persisted project/sidebar/thread state points at a stale/non-git workspace, avoid continuous background Git metadata work against it;
if a workspace has moved or been deleted, clean up or mark the persisted workspace path inactive until explicitly reopened.
This may still relate to the other reports about stale project state and empty .git creation, but the actionable signal from my side is narrower: stale workspace path + invalid empty .git + repeated Git probing.
Before removing the empty .git directory, a 120s sample saw:
115 new git.exe processes
96 new conhost.exe processes
MsMpEng.exe at ~55.6% of one CPU core
After deleting only that empty .git directory, a 60s sample saw:
0 new git.exe processes
0 new conhost.exe processes
MsMpEng.exe at ~1.1% of one CPU core
So in this case Microsoft Defender was not the root cause. It was amplifying Codex's repeated Git probing against an invalid empty .git directory.
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 .git directory was empty.
The patch changes lightweight Git root discovery so an empty .git directory is not treated as a valid repository marker. .git directories now need the minimal structure Git itself accepts (HEAD, objects/, refs/), while .git pointer files using gitdir: remain supported. I also added regression coverage for empty .git directories.
Local validation performed:
git diff --check
Manual git rev-parse --is-inside-work-tree probe confirmed HEAD + objects + refs is accepted by Git while empty/HEAD-only .git directories are rejected.
cargo test was 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 .git trigger, 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 .git directory. I am intentionally omitting the real local path and any user-specific names here.
What finally fixed it locally:
Back up / rename the invalid empty .git directory.
If that workspace path is stale and not needed, removing the invalid .git is enough.
If Codex/project state still points at that workspace and the path needs to remain stable, creating a minimal valid Git repo also works.
For that minimal repo, reduce scan cost with:
git config core.untrackedCache true
git config status.showUntrackedFiles no
and put this in .git/info/exclude:
/*
Verification after fixing the invalid .git:
repeated Codex-launched git.exe probes stopped (git_count=0 during follow-up sampling);
before the fix, nonpaged-pool/file-cache related counters were still climbing over a few minutes;
after the fix, the same counters were effectively flat over the follow-up window;
the visible idle CPU/package-power symptom disappeared.
So this matches the product-side diagnosis already discussed here: Codex should not treat .git existence alone as a valid repository signal. A valid .git/HEAD / gitfile / successful rev-parse check, plus negative caching/backoff for invalid .git directories, would likely prevent this loop.
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.
It starts Codex with a process-scoped GIT_DIR=NUL. On my machine, the stable trace changed from 247 new git.exe and 137 new taskkill.exe processes per 10 seconds to 0 and 0 over 15 seconds; WMI Provider Host fell from about 6.6% to 0.9%.
Usage: fully exit Codex from the Windows system tray, then run the script.
This is an unofficial workaround, not an upstream fix. It deliberately disables or limits Review, Changes, branch detection, commit, and other Git-backed Codex features. It does not patch Codex, modify repositories or Git configuration, write system environment variables, require elevation, terminate processes, or remove chat history. Launching Codex normally restores Git integration.
Related but distinct trigger: our ancestor .git was not empty/invalid. It had a normal Git directory layout but no commits, index, or remotes. The issue was that nested Codex project folders inherited an unintended Git root at %USERPROFILE%.
Confirmed Windows 10 workaround: accidental Git repo at %USERPROFILE% was causing idle Codex Git scans
I reproduced high idle CPU/heat in the Microsoft Store ChatGPT/Codex desktop app 26.1002.7124.0 on Windows 10. No local agent task was running; fully exiting the app reduced the load.
Evidence before the change
The main ChatGPT.exe was launching repeated git.exe subprocesses. One captured command was git ... ls-files --cached -z -- AppData/Local/Packages/....
Five distinct short-lived Git PIDs appeared in ~2.5 seconds.
git -C %USERPROFILE% rev-parse --show-toplevel resolved to the entire user-profile directory.
An unintended %USERPROFILE%\.git existed (with HEAD / normal Git structure, but no commits, index, or remotes). Persisted Codex project directories nested under %USERPROFILE%\.codex\.chatgpt-projects\... thus inherited the profile-level Git root.
A separate real development repository on another drive had its own .git and was unaffected.
Reversible workaround that worked here
Verify whether %USERPROFILE%\.git is actually needed. Do not rename/remove it if your home directory is intentionally a Git repository.
Back up/rename only that unneeded ancestor repo from %USERPROFILE%\.git to a timestamped .git_backup_YYYY-MM-DD; do not delete it.
Restart the app. Verify the home folder is no longer a Git worktree, then verify each actual development repository still resolves to its own Git root.
After: 0 git.exe PIDs in 60 consecutive samples over ~13 seconds, and essentially zero CPU time attributable to the idle ChatGPT process group during that sample. The affected laptop's temperature improved. Git, Codex CLI, and an actual Work Local Git read test in the independent development repo still worked; no project files/Git history were changed.
This is one confirmed local mitigation, not an upstream fix. It does not establish the cause of unrelated taskkill.exe/WMI polling bugs or UI freezes. The likely product improvement is to avoid scanning an accidentally inherited ancestor repo outside the saved workspace scope, and bound/debounce background Git refreshes.
Activity
github-actions commentedon Jun 24, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Yassycodes commentedon Jun 25, 2026
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: #29949 (comment)
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.
GuilhermeCouto commentedon Jun 25, 2026
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.
niderost commentedon Jun 29, 2026
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.
niderost commentedon Jun 29, 2026
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.crash2kx commentedon Jul 1, 2026
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.crash2kx commentedon Jul 1, 2026
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: crash2kx@ad24464
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.keydango27-maker commentedon Jul 5, 2026
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.Snowsword168 commentedon Jul 15, 2026
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.
suiyuebaobao commentedon Jul 22, 2026
The repeated scanning of empty
.gitdirectories and downstream Defender CPU here closely match the behavior I reproduced.I published a single-file Windows launcher for the original Microsoft Store/MSIX Codex app:
It starts Codex with a process-scoped
GIT_DIR=NUL. On my machine, the stable trace changed from 247 newgit.exeand 137 newtaskkill.exeprocesses per 10 seconds to 0 and 0 over 15 seconds; WMI Provider Host fell from about 6.6% to 0.9%.Usage: fully exit Codex from the Windows system tray, then run the script.
This is an unofficial workaround, not an upstream fix. It deliberately disables or limits Review, Changes, branch detection, commit, and other Git-backed Codex features. It does not patch Codex, modify repositories or Git configuration, write system environment variables, require elevation, terminate processes, or remove chat history. Launching Codex normally restores Git integration.
5168413518 commentedon Oct 8, 2026
Related but distinct trigger: our ancestor
.gitwas not empty/invalid. It had a normal Git directory layout but no commits, index, or remotes. The issue was that nested Codex project folders inherited an unintended Git root at%USERPROFILE%.Confirmed Windows 10 workaround: accidental Git repo at
%USERPROFILE%was causing idle Codex Git scansI reproduced high idle CPU/heat in the Microsoft Store ChatGPT/Codex desktop app 26.1002.7124.0 on Windows 10. No local agent task was running; fully exiting the app reduced the load.
Evidence before the change
ChatGPT.exewas launching repeatedgit.exesubprocesses. One captured command wasgit ... ls-files --cached -z -- AppData/Local/Packages/....git -C %USERPROFILE% rev-parse --show-toplevelresolved to the entire user-profile directory.%USERPROFILE%\.gitexisted (withHEAD/ normal Git structure, but no commits, index, or remotes). Persisted Codex project directories nested under%USERPROFILE%\.codex\.chatgpt-projects\...thus inherited the profile-level Git root..gitand was unaffected.Reversible workaround that worked here
%USERPROFILE%\.gitis actually needed. Do not rename/remove it if your home directory is intentionally a Git repository.%USERPROFILE%\.gitto a timestamped.git_backup_YYYY-MM-DD; do not delete it.After: 0
git.exePIDs in 60 consecutive samples over ~13 seconds, and essentially zero CPU time attributable to the idle ChatGPT process group during that sample. The affected laptop's temperature improved. Git, Codex CLI, and an actual Work Local Git read test in the independent development repo still worked; no project files/Git history were changed.This is one confirmed local mitigation, not an upstream fix. It does not establish the cause of unrelated
taskkill.exe/WMI polling bugs or UI freezes. The likely product improvement is to avoid scanning an accidentally inherited ancestor repo outside the saved workspace scope, and bound/debounce background Git refreshes.— Пчеличко (Pchelichko)