A friend is stuck with an old version of Git (I think he said 1.5?), where he says the -b <branch>
option is not supported. I can't wrap my head around it, so I really hope someone could help:
What would be the equivalent of the following command, without using -b
?
git clone -b $BRANCH $REPO
EDIT: I originally asked for git checkout
- that's not what I meant. Sorry!
in older git this required two steps:
git branch $BRANCH $FROM_COMMIT
git checkout $BRANCH
notice i used $FROM_COMMIT
, $REPO
in your question looks odd and misleading – you can only create branches from commits, not from other repositories.
editing my answer, since the question was altered. reading the manpage for git clone, we can see that
-b
Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to branch instead. In a non-bare repository, this is the branch that will be checked out.
to achieve this effect with an older git version we would use:
git clone $REPO
git branch $BRANCH origin/$BRANCH
git checkout $BRANCH
this will set your local HEAD
to the newly created $BRANCH
which is pointing to origin/$BRANCH
(hopefully i'm not mistaken – i don't have a git install here to test …)