Common causes
- A previous Git operation was interrupted and left a stale lock file
- The refs directory has inconsistent entries (e.g. both packed and loose refs conflict)
- Disk I/O errors caused a partial write to the ref store
- Running concurrent Git operations from multiple processes
How to fix it
- Run Git's built-in repair: git gc --prune=now
- Remove stale lock files manually: find .git/refs -name '*.lock' -delete
- Try pruning and fetching: git fetch --prune
- If a specific ref is corrupt: git update-ref -d refs/heads/<branch-name>
Example
error: cannot lock ref 'refs/remotes/origin/feature/test': is at abc123 but expected def456Running git fetch or git pull after an interrupted previous Git operation
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
