Skip to content

Instantly share code, notes, and snippets.

@libitte
Last active November 11, 2022 19:30
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save libitte/cbde168d26bc5faf9bf9fef648091b42 to your computer and use it in GitHub Desktop.
Save libitte/cbde168d26bc5faf9bf9fef648091b42 to your computer and use it in GitHub Desktop.
FIX warning: ignoring broken ref refs/remotes/origin/HEAD

warning: ignoring broken ref refs/remotes/origin/HEAD


➜   ✗ g symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/develop
➜   ✗ g fetch --prune
➜   ✗ g gc

https://www.netroby.com/view/3864

@dlsso
Copy link

dlsso commented Jun 13, 2017

This is one of the first google results for this problem so I'd like to add a little info:

git branch -r is useful here. In my case it showed remote branches but did NOT have origin/HEAD.
In that event you can simply do git remote set-head origin main where "main" is the name of your primary (head) branch.

Running git branch -r again now shows origin/HEAD -> origin/main and the warning goes away.

Some relevant discussion here. Posts by Jeff King are especially informative.

@NoiseEee
Copy link

Thank you disso!

@redec
Copy link

redec commented Sep 14, 2017

WOOT! Thanks dlsso!

@shtratos
Copy link

shtratos commented Nov 8, 2017

Thank you!

@Jose-Solana-Globant
Copy link

Thank you very much, @disso!

@jkogara
Copy link

jkogara commented Apr 7, 2018

Thanks @disso

@vasslitvinov
Copy link

I did not want "HEAD" at all. I removed it using this:

git remote set-head origin -d

@jair-anderson-souza
Copy link

worked for me, thanks.

@fitsyu
Copy link

fitsyu commented Sep 25, 2018

thanks

@waqasajaz
Copy link

in my case primary branch name was "production"
I ran git remote set-head origin production to solve this issue.

@jtmchorse
Copy link

Disso thanks for leaving the comment, it helped me fix my error. Cheers,

@AfzalMasood11
Copy link

Thanks @dlsso

@spier
Copy link

spier commented Oct 21, 2020

👍

@mochadwi
Copy link

Thanks @dlsso

@dexter9code
Copy link

yo that's good no cap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment