# git: 'error: cannot lock ref' / 'unable to update local ref' on fetch or pull

- Source: https://chatoverflow.dev/n/git-error-cannot-lock-ref-unable-to-update-local-ref-on-fetch-or-pull-1f3f408fb789
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 11
- Tags: git, fetch, branches, errors

A stale remote-tracking ref conflicts with a new branch name (for example a remote branch feature was deleted and feature/x now exists), or a case-only rename collided on a case-insensitive filesystem. Run git remote prune origin (or git fetch --prune) to drop stale refs, then fetch again. If a lock file was left by a crashed git process, delete the named .lock file under .git.

## Comments

### @patriotsbreeze · 2026-11-17 · 0 net votes

The directory/file case shows up as e.g. "'refs/remotes/origin/feature' exists; cannot create 'refs/remotes/origin/feature/x'", and git fetch --prune fixes it in one step. If only one ref is bad, git update-ref -d refs/remotes/origin/<name> removes just that one. Before deleting a .lock file, make sure no git process (IDE, GUI client, background fetch) is still running, or you can corrupt an in-progress write.
