codex - 💡(How to fix) Fix Codex VSCode extension corrupts git repositories with `fatal: unable to read sha` and `fatal: Unable to create '.../.git/worktrees/foo/index.lock': File exists.`

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

A workaround is export EDITOR='code --wait --disable-extensions --new-window' to disable all extensions, or disabling or uninstalling the Codex extension.

RAW_BUFFERClick to expand / collapse

What version of the IDE extension are you using?

26.506.31004

What subscription do you have?

Plus

Which IDE are you using?

VS Code

What platform is your computer?

Linux 6.19.14-200.fc43.x86_64 x86_64 unknown

What issue are you seeing?

See repro.

What steps can reproduce the bug?

Repro:

  1. Use a git worktree (I'm using https://github.com/truffleruby/truffleruby a reasonable-size but not small git repository)
  2. Configure: git config --global core.editor 'code --wait'
  3. Ensure VS Code is not already running
  4. Run: git commit enter a message in VSCode, quit with with e.g. Ctrl+W. Might happen more often when not taking long to write the commit message, and maybe also happens more with a larger git repository.
  5. Observe: fatal: unable to read <sha> or: fatal: Unable to create .../.git/worktrees/.../index.lock

Observations:

  • Happens only on VS Code cold start, if VS Code is already running it seems fine
  • git reset --hard HEAD seems to fix the git repository, or rm .../.git/worktrees/.../index.lock
  • code --wait --disable-extensions --reuse-window fixes it
  • Bisected to Codex extension, does not happen with the Codex extension disabled, happens more than half the tries with Codex extension enabled.

A workaround is export EDITOR='code --wait --disable-extensions --new-window' to disable all extensions, or disabling or uninstalling the Codex extension.

A possible cause might be that the Codex extension auto-refresh/git operations are racing on the worktree index during editor startup.

What is the expected behavior?

I would expect the Codex extension to never corrupt my git repository.

Also I expect the Codex extension does not do anything until I start using it, e.g. by opening the Codex chat panel and writing in it.

Additional information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex VSCode extension corrupts git repositories with `fatal: unable to read sha` and `fatal: Unable to create '.../.git/worktrees/foo/index.lock': File exists.`