Agent Shell Commands Timeout on Git Operations, Leaving Stale Lock Files

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Agent mode shell commands consistently timeout when running git operations (add, commit, push), even with extended timeout values up to 120 seconds. When commands are terminated by the timeout, .git/index.lock files are left behind, causing subsequent git commands to fail until manually cleaned up.

Steps to Reproduce

Open a project in Cursor (especially one in an iCloud-synced directory)
Make code changes via Agent mode
Ask the agent to commit and push changes to GitHub
Agent runs shell command: git add && git commit -m “message” && git push origin
Command times out after ~30 seconds (default) or the extended timeout period
.git/index.lock file is left behind
Subsequent git commands fail with:
fatal: Unable to create ‘.git/index.lock’: File exists. Another git process seems to be running in this repository

Expected Behavior

I used to be able to just run Git push commands etc through the IDE with Agent chat. Now I can’t.

Operating System

MacOS

Version Information

Version: 2.4.22 (Universal)
VSCode Version: 1.105.1
Commit: 618c607a249dd7fd2ffc662c6531143833bebd40
Date: 2026-01-26T22:51:47.692Z
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: Darwin arm64 25.1.0

For AI issues: which model did you use?

Auto and tried Claude Opus 4.5 too.

Additional Information

Observed Behavior
Attempt 1 - Default timeout:
Command timed out.The command “git status” did not complete within the timeout period. The shell has been terminated.
Attempt 2 - With extended timeout (60s):
Exit code: 128fatal: Unable to create ‘.git/index.lock’: File exists.
Attempt 3 - After deleting lock file, 90s timeout:
Command timed out.The command “rm -f .git/index.lock && git add … && git commit … && git push origin develop” did not complete within the timeout period. The shell has been terminated.
Attempt 4 - With required_permissions: [‘all’] and 120s timeout:
Command timed out.
Key Observations
Timeout happens regardless of duration - Even 120 seconds wasn’t enough for basic git operations
Lock file cleanup is unreliable - When the shell is terminated, git doesn’t get a chance to clean up .git/index.lock
Previously working - The same agent + repo combination worked fine in previous Cursor versions (user reports “you have been doing it for me the past year”)
Not a permissions issue - Tried with various required_permissions including [‘all’], [‘network’], [‘git_write’]
Not another process - User confirmed no other applications (GitHub Desktop, etc.) were accessing the repo
iCloud path may be a factor - Project is in iCloud Drive, which may add latency to file operations
Expected Behavior
Git commands should complete within reasonable timeouts (30-60s for simple add/commit/push)
If a command must be terminated, cleanup should occur (or at minimum, the agent should automatically remove .git/index.lock before retrying)
Timeout thresholds should be configurable by users

Suggested Workarounds from the Agent:
Running git commands in a regular Terminal.app window outside of Cursor works normally. The agent can make code changes, but git operations must be done manually.
Suggested Fixes:
Increase default timeout for git operations, or make it configurable
Graceful termination - Send SIGTERM before SIGKILL so git can clean up
Auto-cleanup - Detect and remove stale .git/index.lock files before running git commands
Better error handling - If timeout occurs, provide guidance or auto-retry after cleanup

Impact
This bug significantly reduces the usefulness of Agent mode for development workflows that involve git operations. Users who previously relied on the agent for end-to-end coding (edit → commit → push) now have to manually intervene for version control tasks.

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the report. This is a known issue in version 2.4.22. Agent terminal commands can time out or hang, especially with git operations.

Here are a few workarounds (try them in order):

  1. Change Auto-Run Mode (fastest fix)

Cursor Settings > Agents > Auto-Run Mode > switch to “Ask Every Time” instead of auto mode.

A user in a similar thread confirmed this fixes the .git/index.lock issue on macOS.

  1. Disable terminal shell integration

Settings CMD + , > search for terminal.integrated.shellIntegration.enabled > set it to false.

Another user fixed .git/index.lock and other lock file issues this way on Windows.

  1. Roll back to 2.3.34 (if the first two don’t help)

Download it from Download · Cursor and pick version 2.3.34.

Note: if you already used 2.4.x, your chats might break after rolling back due to a format mismatch.

About iCloud: if your project is in iCloud Drive, it can add latency to git operations. If you can, try moving it to a local folder outside iCloud and see if the issue still happens.

Let me know if this doesn’t help.