Git fatal: cannot lock ref

It looks like the problem here was a branch X existed locally, and you tried to create a new branch X/Y. This won’t work, because there will be a file at .git/refs/heads/X, so git can’t also create the folder X.

However, it’s worth adding that including “origin” in your branch name points to some confusion – origin is usually the name of the remote repository. If you run git branch I expect you will see local branches with origin in the name.

The format git checkout X is shorthand for:

  • look for a local branch X and check that out if it exists
  • otherwise look for a remote branch X and check that out locally (git checkout -b X origin/X)

To fix your current state, you can likely do this (see here):

git update-ref -d refs/heads/origin/branch

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)