Git Lock File Issue in Cursor

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Summary

Cursor is creating and holding onto a .git/index.lock file, preventing all git operations (add, commit, push) from working. The lock file persists even when no explicit git operations are being performed through the UI.

Environment

  • OS: Windows 10 (Build 26200)
  • Cursor Version: Multiple processes running (PIDs: 4364, 5156, 6100, 7796, 10524, 13208, 13452, 13576, 14972, 16512, 18220, 19252)
  • Git Version: 2.45.1.windows.1
  • PowerShell Version: 5.1.26100.7462
  • Workspace: c:\ol\legacy-explorer

Issue Details

Lock File Information

  • Location: C:\ol\legacy-explorer\.git\index.lock
  • Created: 1/23/2026 11:34:54 AM
  • Size: 0 bytes (empty lock file)
  • Status: File exists and cannot be deleted (access denied)

Error Messages

fatal: Unable to create 'C:/ol/legacy-explorer/.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.

Affected Operations

  • git add - FAILS
  • git commit - FAILS
  • git push - FAILS (also has network/proxy issue)
  • Any git operation that requires index access

Steps to Reproduce

Steps to Reproduce

  1. Open a git repository in Cursor
  2. Make some file changes
  3. Attempt to stage changes via terminal: git add <file>
  4. Observe error: lock file already exists

Evidence

  • No other git processes running (verified via Get-Process)
  • Only Cursor processes are active
  • Lock file was created at 11:34:54 AM (recent, during active Cursor session)
  • Lock file is empty (0 bytes), suggesting a crashed or stuck process
  • Cannot delete lock file (access denied), indicating Cursor is holding a handle to it

Expected Behavior

Expected Behavior

  • Cursor should properly clean up git lock files after operations complete
  • Lock files should not persist when no git operations are active
  • Manual git operations via terminal should work independently of Cursor’s git operations

Operating System

Windows 10/11

Version Information

Version: 2.4.21 (user setup)
VSCode Version: 1.105.1
Commit: dc8361355d709f306d5159635a677a571b277bc0
Date: 2026-01-22T16:57:59.675Z
Build Type: Stable
Release Track: Default
Electron: 39.2.7
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT x64 10.0.26200

For AI issues: which model did you use?

Composer 1

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

1 Like

Hey, thanks for the detailed report.

This looks like a known issue. Cursor can keep a handle on the .git/index.lock file, which blocks Git operations. We had a similar bug that was fixed, but this looks like either a regression or an incomplete fix.

Workaround for now:

  1. Fully close Cursor (make sure all processes are closed)
  2. Manually delete .git/index.lock
  3. Restart Cursor

If the file still can’t be deleted after closing Cursor, please check Process Explorer or Task Manager to confirm all cursor.exe processes are actually terminated.

If this keeps happening regularly, I can pass it to the team to investigate. Let me know how it goes.

That’s does not work, cursor complains again about index.lock

FWIW last time I tried closing and starting cursor:

  • Close cursor.

  • Go to repo and delete index.lock

  • Stage changes and commit with command line git.

  • Start cursor.

  • In chat “push“ and the problem surfaces again.

1 Like

Having the same issue on macOS in auto mode, issue went away after switching to Opus 4.5 but still getting the error with auto mode. Seem to happen when the agent tries running too many git operations at once.

fatal: Unable to create '/Users/**/.git/index.lock': Operation not permitted

I have a similar issue with Git. Additionally, I’m having a problem running pytest — it locks the .coverage file.

How I Fixed Git and Coverage File Locking Issues After Cursor Update

After updating Cursor, I encountered two issues:

  1. Git commands were failing with file locking errors (similar to index.lock problems)

  2. Coverage files (.coverage*) were getting locked during test runs, causing PermissionError: [WinError 5] Access is denied

Root Cause:

The problem was caused by Cursor’s terminal shell integration feature, which was interfering with file operations. The integration wrapper was trying to collect environment variables after each command execution, causing conflicts with file locks.

Solution:

I disabled the shell integration by adding the following setting to Cursor’s user settings file:

File: Roaming\Cursor\User\settings.json

Change:

{

"terminal.integrated.shellIntegration.enabled": false

}

Results:

  1. Git commands now work without locking issues — git status and git diff execute successfully

  2. Coverage files can be written properly — tests run with coverage reporting without permission errors.

In short, the previous setup also didn’t work well. The MCP server on GitHub didn’t understand it, and the glitches were still there. Only rolling back to version 2.3 helped. Now it’s fine with that version, like it was before.