[BUG]
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
On Windows, Claude Code creates and holds a .git/index.lock file open for the duration of the session, blocking all git operations in the working directory. The lock appears immediately on session start, before any commands are run. It persists until Claude Code is closed, at which point git works normally again. Re-opening Claude Code immediately recreates the lock.
What Should Happen?
Claude Code should not hold a lock on .git/index.lock between commands. Any git commands run at startup (e.g. to populate the gitStatus context) should release all file handles when they complete, leaving the repository accessible to the user and other tools.
Error Messages/Logs
Steps to Reproduce
- Open Claude Code in a directory that is a git repository (Windows 10)
- Run no commands — simply open the session
- In a separate terminal, attempt any git operation (e.g. git add, git status)
- Observe: fatal: Unable to create '.git/index.lock': File exists
- Close Claude Code
- Observe: the lock file disappears and git works normally
- Re-open Claude Code — the lock immediately returns
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.183
Platform
Other
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
<img width="1418" height="496" alt="Image" src="https://github.com/user-attachments/assets/10b5f93d-ab99-4268-8e74-ed6211cc0795" />
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗