git clone -b

2 messages, 2 authors, 2017-05-08 · open the first message on its own page

git clone -b

From: Дилян Палаузов <hidden>
Date: 2017-05-08 06:30:57

Hello,

why do these work:

git clone --bare -b 3.5 https://github.com/python/cpython A
git clone -b 3.6 A B
git clone -b 3.5 https://github.com/python/cpython C

but these not:

git clone -b 3.6 C D
git clone --no-local -b 3.6 C D

with git version 2.12.2.89.g49800c940?

Regards
  Дилян

Re: git clone -b

From: Jeff King <hidden>
Date: 2017-05-08 07:42:54

On Mon, May 08, 2017 at 08:30:49AM +0200, Дилян Палаузов wrote:
why do these work:

git clone --bare -b 3.5 https://github.com/python/cpython A
git clone -b 3.6 A B
From the description of --bare in "git help clone":

  [...]the branch heads at the remote are copied directly to
  corresponding local branch heads, without mapping them to
  refs/remotes/origin/. When this option is used, neither
  remote-tracking branches nor the related configuration variables are
  created.

So because the upstream has a refs/heads/3.6 branch, so too does the
bare clone "A". And thus when you clone it asking for that branch, Git
can find it.

But in your non-bare example:
git clone -b 3.5 https://github.com/python/cpython C

but these not:

git clone -b 3.6 C D
git clone --no-local -b 3.6 C D
In the non-bare clone C, there is no local 3.6 branch. You only have the
remote-tracking branch refs/remotes/origin/3.6. So when you try to clone
from it, Git can't find the branch:

  $ git clone -b 3.6 C D
  Cloning into 'D'...
  fatal: Remote branch 3.6 not found in upstream origin
  fatal: The remote end hung up unexpectedly

It works if you create a local branch based on upstream's branch:

  $ git -C C checkout 3.6
  Branch 3.6 set up to track remote branch 3.6 from origin.
  Switched to a new branch '3.6'

  $ git clone -b 3.6 C D
  Cloning into 'D'...
  done.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help