Skip to content

Repository files navigation

CodexGitGuard

An event-driven Windows workaround for an issue where Codex or ChatGPT Work can create an empty .git directory and repeatedly probe it with Git. In some affected workspaces this can cause repeated git.exe activity and elevated CPU or power usage.

This is a temporary user-side mitigation, not an OpenAI product or an official fix. Track the upstream issue before relying on it long term: openai/codex#29911

What it does

  • Watches one folder tree with the Windows filesystem event API.
  • Removes a child directory named .git only after it remains empty across two checks (600 ms by default).
  • Preserves non-empty Git repositories, .git pointer files used by worktrees, and reparse points.
  • Has no Node.js or Python dependency, no idle tree polling, no logging, and no process termination.
  • Runs as the current Windows user at logon through a scheduled task named CodexGitGuard.

What it does not do

  • It does not fix Codex or ChatGPT Work.
  • It does not stop every possible CPU, Defender, Node.js, Python, or disk-write problem.
  • It deliberately does not delete non-empty or otherwise invalid .git directories. Inspect those manually.
  • It does not monitor folders outside the root you choose.

Install

  1. Download or clone this repository.
  2. Double-click Install-CodexGitGuard.bat.
  3. Enter the parent folder containing your ChatGPT Work folders, for example D:\Projects\ChatGPT-Work.
  4. The window reports the installed root and task state. The guard starts immediately and again at your next sign-in.

Run Uninstall-CodexGitGuard.bat from this repository to remove the scheduled task and its installed copy under %LOCALAPPDATA%\CodexGitGuard.

For scripted installation:

.\CodexGitGuard.ps1 -Mode Install -Root 'D:\Projects\ChatGPT-Work'

Verify safely

Run the built-in checks first:

.\CodexGitGuard.ps1 -Mode SelfTest

The self-test creates temporary paths and verifies that an empty .git directory is removed while a non-empty repository and a .git pointer file are preserved. It does not touch the chosen work root.

Then, in a disposable subfolder below your monitored root, create an empty .git directory. It should disappear after roughly 0.6 to 1 second. Do not create an empty .git directory in a repository you care about just for a test.

Check the installed task at any time:

.\CodexGitGuard.ps1 -Mode Status

Alternative mitigation for a fixed workspace

If a particular workspace must stay at a stable path, an alternative reported by affected users is to make it a minimal valid Git repository rather than leave an empty .git directory. This changes Git behavior for that folder, so it is not the default approach here. A conservative starting point is:

git init
git config core.untrackedCache true
git config status.showUntrackedFiles no
Set-Content -LiteralPath .git\info\exclude -Value '/*' -Encoding ASCII

Keep this guard as a fallback for other workspace folders. Do not use the alternative in an existing repository without understanding its Git settings.

Safety model

The only automatic deletion is an empty directory whose final path component is exactly .git, located below the root selected at installation. A directory with even one entry, a .git file, or a reparse point is left untouched.

The guard is intentionally conservative: it does not kill git.exe processes. If an affected system continues to show a process burst after the empty directory is removed, capture the command line and report it upstream rather than applying a broad process-kill rule.

Requirements

  • Windows 10 or Windows 11
  • Windows PowerShell 5.1 or later
  • Permission to create a per-user scheduled task

Git is not required by the guard itself.

License

MIT. See LICENSE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages