{"thread":{"id":"45899","subject":"git clone -b","startedAt":"2017-05-08T06:30:57Z","lastAt":"2017-05-08T07:42:54Z","messageCount":2,"participants":["Дилян Палаузов","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319060","messageId":"219f3882-ec66-5c36-a157-5b920a2e4d04@aegee.org","threadId":"45899","inReplyTo":null,"subject":"git clone -b","fromName":"Дилян Палаузов","fromEmail":"dilyan.palauzov@aegee.org","sentAt":"2017-05-08T06:30:49Z","receivedAt":"2017-05-08T06:30:57Z","isPatch":false,"sender":{"key":"dilyan.palauzov@aegee.org","avatar":null},"body":"Hello,\n\nwhy do these work:\n\ngit clone --bare -b 3.5 https://github.com/python/cpython A\ngit clone -b 3.6 A B\ngit clone -b 3.5 https://github.com/python/cpython C\n\nbut these not:\n\ngit clone -b 3.6 C D\ngit clone --no-local -b 3.6 C D\n\nwith git version 2.12.2.89.g49800c940?\n\nRegards\n   Дилян\n"},{"id":"319068","messageId":"20170508074244.tcu2ywil2m47375k@sigill.intra.peff.net","threadId":"45899","inReplyTo":"219f3882-ec66-5c36-a157-5b920a2e4d04@aegee.org","subject":"Re: git clone -b","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-05-08T07:42:44Z","receivedAt":"2017-05-08T07:42:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 08, 2017 at 08:30:49AM +0200, Дилян Палаузов wrote:\n\n> why do these work:\n> \n> git clone --bare -b 3.5 https://github.com/python/cpython A\n> git clone -b 3.6 A B\n\nFrom the description of --bare in \"git help clone\":\n\n  [...]the branch heads at the remote are copied directly to\n  corresponding local branch heads, without mapping them to\n  refs/remotes/origin/. When this option is used, neither\n  remote-tracking branches nor the related configuration variables are\n  created.\n\nSo because the upstream has a refs/heads/3.6 branch, so too does the\nbare clone \"A\". And thus when you clone it asking for that branch, Git\ncan find it.\n\nBut in your non-bare example:\n\n> git clone -b 3.5 https://github.com/python/cpython C\n> \n> but these not:\n> \n> git clone -b 3.6 C D\n> git clone --no-local -b 3.6 C D\n\nIn the non-bare clone C, there is no local 3.6 branch. You only have the\nremote-tracking branch refs/remotes/origin/3.6. So when you try to clone\nfrom it, Git can't find the branch:\n\n  $ git clone -b 3.6 C D\n  Cloning into 'D'...\n  fatal: Remote branch 3.6 not found in upstream origin\n  fatal: The remote end hung up unexpectedly\n\nIt works if you create a local branch based on upstream's branch:\n\n  $ git -C C checkout 3.6\n  Branch 3.6 set up to track remote branch 3.6 from origin.\n  Switched to a new branch '3.6'\n\n  $ git clone -b 3.6 C D\n  Cloning into 'D'...\n  done.\n\n-Peff\n"}]}