{"thread":{"id":"19425","subject":"Quick way to clone exactly one branch","startedAt":"2009-05-20T20:45:44Z","lastAt":"2009-05-28T20:32:00Z","messageCount":4,"participants":["Avery Pennarun","Jeff King","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114368","messageId":"32541b130905201345h6daa84e8hb937e1e46456b3c5@mail.gmail.com","threadId":"19425","inReplyTo":null,"subject":"Quick way to clone exactly one branch","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2009-05-20T20:45:44Z","receivedAt":"2009-05-20T20:45:44Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"Hi all,\n\nIs there a quick alternative to the following?\n\n   mkdir myproj\n   cd myproj\n   git init\n   git fetch git://whatever master\n   git checkout -b master FETCH_HEAD\n\nBasically, the above is a lot like 'git clone' but only clones the\n'master' branch.  For really big projects with lots of junk in other\nbranches, the above can save a lot of bandwidth.\n\nAlso, if I were using git clone, I would often use --reference above.\nI'm kind of afraid of explaining to a newbie that they should add an\nentry to .git/objects/info/alternates after step 3.\n\nAm I missing something obvious?\n\nHave fun,\n\nAvery\n"},{"id":"114955","messageId":"20090528201503.GL13499@coredump.intra.peff.net","threadId":"19425","inReplyTo":"32541b130905201345h6daa84e8hb937e1e46456b3c5@mail.gmail.com","subject":"Re: Quick way to clone exactly one branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-28T20:15:03Z","receivedAt":"2009-05-28T20:15:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 20, 2009 at 04:45:44PM -0400, Avery Pennarun wrote:\n\n> Is there a quick alternative to the following?\n> \n>    mkdir myproj\n>    cd myproj\n>    git init\n>    git fetch git://whatever master\n>    git checkout -b master FETCH_HEAD\n> \n> Basically, the above is a lot like 'git clone' but only clones the\n> 'master' branch.  For really big projects with lots of junk in other\n> branches, the above can save a lot of bandwidth.\n\nNo, AFAIK there isn't a simpler way to do it. But it is something people\nhave asked about before, so I think it would be a nice addition.\n\nYou can't even use \"git remote\" because it doesn't allow you to tweak\nthe refspecs you add. To do it \"just like clone\" I think you would have\nto:\n\n  git config remote.origin.url git://whatever\n  git config remote.origin.fetch refs/heads/master:refs/remotes/origin/master\n\nIt would be nice if that could be:\n\n  git remote add -b master origin git://whatever\n\nand then make it available as:\n\n  git clone -b master git://whatever\n\nMultiple \"-b <branch>\" options would generate refspecs to pull multiple\nbranches. You could even allow \"git clone --refspec=<whatever>\", but I\ndon't know what you would use that much flexibility for (and at that\npoint, you are probably comfortable enough to write the config\nyourself).\n\n-Peff\n"},{"id":"114956","messageId":"m3ljohas9x.fsf@localhost.localdomain","threadId":"19425","inReplyTo":"20090528201503.GL13499@coredump.intra.peff.net","subject":"Re: Quick way to clone exactly one branch","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-28T20:26:05Z","receivedAt":"2009-05-28T20:26:05Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Wed, May 20, 2009 at 04:45:44PM -0400, Avery Pennarun wrote:\n> \n> > Is there a quick alternative to the following?\n> > \n> >    mkdir myproj\n> >    cd myproj\n> >    git init\n> >    git fetch git://whatever master\n> >    git checkout -b master FETCH_HEAD\n> > \n> > Basically, the above is a lot like 'git clone' but only clones the\n> > 'master' branch.  For really big projects with lots of junk in other\n> > branches, the above can save a lot of bandwidth.\n> \n> No, AFAIK there isn't a simpler way to do it. But it is something people\n> have asked about before, so I think it would be a nice addition.\n> \n> You can't even use \"git remote\" because it doesn't allow you to tweak\n> the refspecs you add. [...]\n\nIt doesn't? Strange, I thought that is what '-t <branch>' option\nfor \"git remote add\" for ;-))))\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"114958","messageId":"20090528203200.GA14576@coredump.intra.peff.net","threadId":"19425","inReplyTo":"m3ljohas9x.fsf@localhost.localdomain","subject":"Re: Quick way to clone exactly one branch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-28T20:32:00Z","receivedAt":"2009-05-28T20:32:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 28, 2009 at 01:26:05PM -0700, Jakub Narebski wrote:\n\n> > No, AFAIK there isn't a simpler way to do it. But it is something people\n> > have asked about before, so I think it would be a nice addition.\n> > \n> > You can't even use \"git remote\" because it doesn't allow you to tweak\n> > the refspecs you add. [...]\n> \n> It doesn't? Strange, I thought that is what '-t <branch>' option\n> for \"git remote add\" for ;-))))\n\nOh, indeed. For some reason I thought that was about setting up tracking\nfor branches. So yes, Avery would be much better off in his example with\n\n    git remote add -t master origin git://whatever\n\nBut it would still be even nicer to have \"clone -t master\".\n\n-Peff\n"}]}