0

Today i faced this issue when i am trying to push commits from Github desktop. Everytime I am facing this issue.

error: cannot lock ref 'refs/remotes/origin/main': unable to resolve reference 'refs/remotes/origin/main': reference broken
 ! [new branch]        main       -> origin/main  (unable to update local ref)

For some reason this how github desktop push button looks like

git remote set-head origin resources tried solutions like this bu none of them fixed my problem.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • Did you try a `git fetch`? – Code-Apprentice Sep 18 '21 at 00:31
  • 1
    Related: https://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref – Code-Apprentice Sep 18 '21 at 00:32
  • @Code-Apprentice Still having the same problem error: cannot lock ref 'refs/remotes/origin/main': unable to resolve reference 'refs/remotes/origin/main': reference broken From https://github.com/kafigaming/resources ! [new branch] main -> origin/main (unable to update local ref) – Mohammed Amwar Sep 18 '21 at 00:35
  • 1
    Try running `git update-ref -d refs/remotes/origin/main`. This, if successful, will remove your `origin/main` remote-tracking branch entirely; Git should be able to re-create it later. This *should not be necessary* though because Git should be able to update `refs/remotes/origin/main` in place anyway. – torek Sep 18 '21 at 00:51
  • @torek error: cannot lock ref 'refs/remotes/origin/main': unable to resolve reference 'refs/remotes/origin/main': reference broken Hi torek thanks for your kind response i did try to run I am getting this error – Mohammed Amwar Sep 18 '21 at 01:01
  • Does your remote repository have a branch named `main`? Or did someone delete it or rename it on accident/on purpose? – Code-Apprentice Sep 18 '21 at 01:54
  • @code-apprentice yes i do have a branch named main – Mohammed Amwar Sep 18 '21 at 02:30
  • Interesting: update-ref should delete the ref even if it *is* broken. This indicates a bug in Git. What version are you running? – torek Sep 18 '21 at 03:02
  • I am using github desktop 2.9.3 https://prnt.sc/1sorypz for some reason i cant see main on this VDS @torek – Mohammed Amwar Sep 18 '21 at 11:29
  • "github desktop" is a different program (a GUI); your `git branch -r` suggests you're using one of the standard Git distributions. But Git version 2.9.3 is way out of date, so upgrade and see if that fixes the problem. Current versions of Git are about 2.33, but anything past about 2.20 should be OK. – torek Sep 18 '21 at 13:48
  • I am not using git, as i said on the topic I am using github desktop @torek – Mohammed Amwar Sep 18 '21 at 15:30
  • If you're not using Git, stop wasting everyone's time. You tagged this with [tag:git], not [tag:github-desktop]. These are *different programs*. (But your `git branch -r` at the command line was command-line Git, and that's the Git version I'm asking about. `git --version` will tell you the version.) – torek Sep 18 '21 at 15:48

0 Answers0