dev@local: ~/project — git
dev@local~/project$TEST
fatal: cannot lock ref
Diagnostics Translation
Git could not update a specific branch pointer because it is locked or corrupted.
waiting for resolution...
MediumVersion Control System
Reviewed for reference consistency: April 11, 2026
Code is Safe
SECUREGit has paused the operation to protect your code. No data has been lost or corrupted.
What To Know
This state means Git could not safely take exclusive control of the branch reference file it needed to update.
Where Did It Fail?
Working Tree
Your local files
add
Staging Index
Prepared changes
commit
Local Repo
Commit history
push/fetch
Remote Server
GitHub/GitLab
The error involves the internal Git database or commit history structure.
Commands That Trigger This
$TEST
Trying to pull a branch named on Windows when a branch named `test` already exists
$.git/refs/heads/main
A power failure corrupted the file
Technical Background
01
On macOS and Windows, filesystems are case-insensitive. If remote developers create branches differing only by capitalization, your local Git client will try to write two different branches into the exact same file, causing a lock failure.
02
Non-corruption variants usually come from a stale lock, a competing Git process, or a ref-name collision that prevents Git from claiming the branch pointer cleanly.
Underlying Causes
A stale lock file exists in `.git/refs/heads/`
A branch name casing conflict on case-insensitive filesystems (e.g., `Feature` vs `feature`)
The branch reference file is physically corrupted or empty
Frequently Asked Questions
Index lock affects the staging area (all files). Ref lock affects only the specific branch pointer you are trying to update.