views:

305

answers:

1

I have a remote repository http://github.com/fernandezpablo85/Test

This repo has a master branch, but it's behind two other branches so when I clone it I get this warining:

warning: remote HEAD refers to nonexistent ref, unable to checkout.

And also I don't get a local master branch (git branch shows nothing).

I can fix the whole thing doing:

git checkout -b master origin/master

But I was wondering why this happens? Is master supposed to be the more advanced branch? Or is there something else wrong with my repo?

+1  A: 

1/ No, master is not necessary the most advanced branch. One can publish only to another branch, and then delete that branch...

2/ When that happen, you should select master as the default branch from the admin panel of the github repo, but that is not always possible. See this bug

For anyone else who has hit this issue:

tekkub told me how to get around this bug via the freenode #github channel.

  • create a temporary branch,
  • push that to your repo,
  • select the default branch in the admin panel for that repo,
  • then delete the branch and push again.

Worked for us.

(the idea is to temporary have two branches, in order to be able to select master as default with the GUI admin panel, and then delete the extra branch)

VonC
Ok. That's a solution to the problem and thanks for that. But I wanted to know __why__ that happens. Or at least to know if it's a github thing instead of a git issue
Pablo Fernandez
@Pablo: why: because you delete a remote branch on which you had push some commits (and not on the remote master). The GitHub part is only related to their admin console, displaying that deleted remote branch as the default, and preventing the user to change the default branch to master. That bit is a GUI issue, not a Git issue.
VonC