# fatal: Unable to create '.git/objects/pack/pack-abc123.idx.lock': File exists.

- **ID:** `git/gc-lock-file-error`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Another git process (e.g., gc or fetch) is already running and holds the lock file, preventing the current operation from proceeding.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.40.0 | active | — | — |
| 2.41.0 | active | — | — |
| 2.42.0 | active | — | — |

## Workarounds

1. **Check for running git processes: 'ps aux | grep git'. If found, wait for them to finish or kill them gently (e.g., 'kill <PID>'). Then remove the stale lock file: 'rm -f .git/objects/pack/pack-abc123.idx.lock'.** (95% success)
   ```
   Check for running git processes: 'ps aux | grep git'. If found, wait for them to finish or kill them gently (e.g., 'kill <PID>'). Then remove the stale lock file: 'rm -f .git/objects/pack/pack-abc123.idx.lock'.
   ```
2. **If no git process is running, the lock file is stale. Remove it: 'rm -f .git/objects/pack/pack-abc123.idx.lock'. Then retry the operation.** (90% success)
   ```
   If no git process is running, the lock file is stale. Remove it: 'rm -f .git/objects/pack/pack-abc123.idx.lock'. Then retry the operation.
   ```

## Dead Ends

- **Deleting the .lock file immediately without checking for other processes.** — If another git process is still running, deleting the lock file can cause corruption or race conditions. (60% fail)
- **Running 'git gc' again to force the lock to be released.** — This will likely fail with the same error because the lock is already held. It may also start another gc process, making things worse. (80% fail)
- **Rebooting the system to clear all processes.** — Overkill and unnecessary; a simple process check and kill is sufficient. Also disrupts other work. (90% fail)
