Bash tool: git add with multiple paths silently runs in background and holds index.lock indefinitely
Summary
When running git add with multiple paths/directories in a single command via the Bash tool, the command is silently moved to background execution. The background process holds .git/index.lock and never releases it (or takes extremely long), blocking all subsequent git operations.
Steps to Reproduce
In a Claude Code session:
- Run a
git addwith multiple paths:
``bash`
git add path/to/dir1/ path/to/file1 path/to/file2
Command running in background with ID: <id>
→ Output: (no error shown).git/index.lock` is created and held
→
- Try any subsequent git command:
``bash`
git status
fatal: Unable to create '.git/index.lock': File exists.`
→
Expected Behavior
git add with multiple paths should run synchronously in the foreground (as it does with a single path).
Actual Behavior
- Single-path
git addruns in the foreground and completes immediately - Multi-path
git addis silently deferred to background, holds the lock, and eventually fails with exit code 144
Exit code 144 is returned by all background git add tasks, suggesting the process is terminated by a signal (128 + 16 = SIGURG?) or a sandbox enforcement mechanism.
Environment
- Claude Code CLI
- macOS Darwin 25.3.0
- git version 2.50.1 (Apple Git-155)
- Sandbox enabled (
sandbox.enabled: true) excludedCommands: ["git:*"]configured in project settings
Workaround
Run git add with one path at a time:
# Works
git add path/to/dir1/
git add path/to/file1
Impact
Makes it impossible to stage multiple files/directories in a single tool call, requiring a workaround of individually calling git add for each path — and even then, a stale lock from a prior background run must be manually removed first.
Additional Notes
- The background task output file is always empty (no stderr captured)
- The issue does not occur with
dangerouslyDisableSandbox: truedisabled (same behavior) - Killing the background process with
pkill -f "git add"and removing.git/index.lockmanually is the only recovery path
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗