Git clone does not bring master branch

Pablo Fernandez picture Pablo Fernandez · Jan 6, 2010 · Viewed 12.8k times · Source

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?

Answer

Greg Franko picture Greg Franko · Apr 26, 2012

If you only want to clone the master branch, then run this command:

git clone [email protected]:**username**/ **Repository URL** -b master

Here is an example:

git clone [email protected]:gfranko/jquery.selectBoxIt.js.git -b master