ProjectStack
git

error: cannot lock ref — reference broken

Git can't update a reference (branch pointer) because it's in a broken or locked state. This often means the ref store has inconsistent or corrupt entries.

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

  1. Run Git's built-in repair: git gc --prune=now
  2. Remove stale lock files manually: find .git/refs -name '*.lock' -delete
  3. Try pruning and fetching: git fetch --prune
  4. 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 def456

Running 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.