[BUG] Stale .git/index.lock left behind after Bash tool git commands on Windows

Open 💬 13 comments Opened Feb 25, 2026 by ls-edwin-bekaert

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?

After Claude Code runs git commands via the Bash tool on Windows, .git/index.lock files are left behind. This blocks subsequent git operations from other tools (e.g., JetBrains Rider, VS Code, manual git CLI).

This does not happen when running the same git commands manually in the same terminal. It only occurs when CC's Bash tool executes git.

Previous issue #11005 documented this on Linux/macOS and was closed as NOT_PLANNED. This report is specifically about Windows where the problem is more severe due to Windows' stricter file handle semantics.

Error Message

Unable to create 'C:/DATA/git/project/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

Steps to Reproduce

  1. Open Claude Code on Windows
  2. Let CC run any git command via Bash tool (e.g., git status, git add, git commit)
  3. Immediately switch to another tool (Rider, VS Code, or another terminal) and run a git command
  4. Observe index.lock error

What Should Happen?

Git's .git/index.lock should be cleaned up before the Bash tool returns control. On Windows, this likely requires ensuring the child process (and any subprocess handles) are fully terminated and file handles released before the tool result is sent back.

Likely Cause

On Windows, file handles are not released as eagerly as on Unix. When CC's Bash tool terminates or times out a child process, the git process may not have fully released its lock file. Windows keeps the file locked as long as any handle to it exists, even if the process has logically completed.

Workaround

Manually delete the lock file:

del C:\DATA\git\project\.git\index.lock

Environment

  • OS: Windows 11 Enterprise 10.0.26200
  • Shell: Git Bash
  • Claude Code: Latest (CLI)
  • Related: #11005 (closed, NOT_PLANNED — focused on Linux/macOS)

View original on GitHub ↗

This issue has 13 comments on GitHub. Read the full discussion on GitHub ↗