{"thread":{"id":"18188","subject":"Clone a repo and checkout a specifc remote branch","startedAt":"2009-03-07T11:42:37Z","lastAt":"2009-03-07T23:25:15Z","messageCount":3,"participants":["Paolo Ciarrocchi","Patrick Notz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"107288","messageId":"4d8e3fd30903070342q584315cjcd059dcfe558dcfd@mail.gmail.com","threadId":"18188","inReplyTo":null,"subject":"Clone a repo and checkout a specifc remote branch","fromName":"Paolo Ciarrocchi","fromEmail":"paolo.ciarrocchi@gmail.com","sentAt":"2009-03-07T11:42:37Z","receivedAt":"2009-03-07T11:42:37Z","isPatch":false,"sender":{"key":"paolo.ciarrocchi@gmail.com","avatar":null},"body":"Hi list,\nI've got a few questions from a friend that used git for the first\ntime, I answered to all of them but the following.\n\nScenario:\nHe knows the URl of a git repository which contains a few branches. He\nis interested only to a single specific branch.\nHe expected to manage to clone the specific remote branch with a\nsingle command, instead he had to learn the following procedure:\n\n$ git clone git://uri_of_the_repo localdir\n$ cd localdir\n$ git branch\n* master\n# OK, so now he cloned the whole repository and checked out the master branch\n$ git checkout mybranch origin/coolbranch\n\nWouldn't be an improvement to let the user to specify which remote\nbranch he want to be checked out after a clone?\nSomething like:\n$ git clone git://uri_of_the_repo:coolbranch localdir\nto get a clone of the whole repository and to check out the\norigin/coolbranch remote branch?\n\nI quickly discussed this scenario on the #git channel and a user\nsuggested to use the following procedure:\n$ git init\n$ git fetch git://uri_of_the_repo coolbranch\nwhich was new to me, I tried it as follow:\n$ git fetch git://git.kernel.org/pub/scm/git/git.git man\nremote: Counting objects: 7319, done.←[K\nremote: Compressing objects: 100% (1536/1536), done.←[K\nremote: Total 7319 (delta 5640), reused 7290 (delta 5625)←[K\nReceiving objects: 100% (7319/7319), 1.40 MiB | 110 KiB/s, done.\nResolving deltas: 100% (5640/5640), done.\nFrom git://git.kernel.org/pub/scm/git/git\n * branch            man        -> FETCH_HEAD\n\nbut now I don't understand how to checkout the branch :-/\n\nCiao,\n-- \nPaolo\nhttp://paolo.ciarrocchi.googlepages.com/\nhttp://mypage.vodafone.it/\n"},{"id":"107322","messageId":"1cd1989b0903071053l3f7aa35bu8e8e6b7e56cfc34f@mail.gmail.com","threadId":"18188","inReplyTo":"4d8e3fd30903070342q584315cjcd059dcfe558dcfd@mail.gmail.com","subject":"Re: Clone a repo and checkout a specifc remote branch","fromName":"Patrick Notz","fromEmail":"patnotz@gmail.com","sentAt":"2009-03-07T18:53:56Z","receivedAt":"2009-03-07T18:53:56Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"On Sat, Mar 7, 2009 at 4:42 AM, Paolo Ciarrocchi\n<paolo.ciarrocchi@gmail.com> wrote:\n> Hi list,\n> I've got a few questions from a friend that used git for the first\n> time, I answered to all of them but the following.\n>\n> Scenario:\n> He knows the URl of a git repository which contains a few branches. He\n> is interested only to a single specific branch.\n> He expected to manage to clone the specific remote branch with a\n> single command, instead he had to learn the following procedure:\n>\n> $ git clone git://uri_of_the_repo localdir\n> $ cd localdir\n> $ git branch\n> * master\n> # OK, so now he cloned the whole repository and checked out the master branch\n> $ git checkout mybranch origin/coolbranch\n>\n> Wouldn't be an improvement to let the user to specify which remote\n> branch he want to be checked out after a clone?\n> Something like:\n> $ git clone git://uri_of_the_repo:coolbranch localdir\n> to get a clone of the whole repository and to check out the\n> origin/coolbranch remote branch?\n>\n\nHere's a link to a recent thread on this topic (that started with a\nproposed patch)\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/111967\n\nYou can read the arguments there.  Johannes Schindelin noted that the\nnormal way to do this is like this:\n\n<quote>\nBesides, the common way to check out something different than the remote's\nHEAD is like this:\n\n$ git clone -n $URL\n$ cd $DIR\n$ git checkout -t origin/$BRANCH\n</quote>\n\n\n> I quickly discussed this scenario on the #git channel and a user\n> suggested to use the following procedure:\n> $ git init\n> $ git fetch git://uri_of_the_repo coolbranch\n> which was new to me, I tried it as follow:\n> $ git fetch git://git.kernel.org/pub/scm/git/git.git man\n> remote: Counting objects: 7319, done.←[K\n> remote: Compressing objects: 100% (1536/1536), done.←[K\n> remote: Total 7319 (delta 5640), reused 7290 (delta 5625)←[K\n> Receiving objects: 100% (7319/7319), 1.40 MiB | 110 KiB/s, done.\n> Resolving deltas: 100% (5640/5640), done.\n> From git://git.kernel.org/pub/scm/git/git\n>  * branch            man        -> FETCH_HEAD\n>\n> but now I don't understand how to checkout the branch :-/\n>\n> Ciao,\n> --\n> Paolo\n> http://paolo.ciarrocchi.googlepages.com/\n> http://mypage.vodafone.it/\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"107356","messageId":"4d8e3fd30903071525g27960764rbc1cee77e4334a6e@mail.gmail.com","threadId":"18188","inReplyTo":"1cd1989b0903071053l3f7aa35bu8e8e6b7e56cfc34f@mail.gmail.com","subject":"Re: Clone a repo and checkout a specifc remote branch","fromName":"Paolo Ciarrocchi","fromEmail":"paolo.ciarrocchi@gmail.com","sentAt":"2009-03-07T23:25:15Z","receivedAt":"2009-03-07T23:25:15Z","isPatch":false,"sender":{"key":"paolo.ciarrocchi@gmail.com","avatar":null},"body":"On 3/7/09, Patrick Notz <patnotz@gmail.com> wrote:\n\n>> Something like:\n>> $ git clone git://uri_of_the_repo:coolbranch localdir\n>> to get a clone of the whole repository and to check out the\n>> origin/coolbranch remote branch?\n>>\n>\n> Here's a link to a recent thread on this topic (that started with a\n> proposed patch)\n>\n> http://thread.gmane.org/gmane.comp.version-control.git/111967\n>\n> You can read the arguments there.  Johannes Schindelin noted that the\n> normal way to do this is like this:\n>\n> <quote>\n> Besides, the common way to check out something different than the remote's\n> HEAD is like this:\n>\n> $ git clone -n $URL\n> $ cd $DIR\n> $ git checkout -t origin/$BRANCH\n> </quote>\n\nThank you, very appreciated, I missed that discussion.\n\nI'll add my comments to that thread.\n\nRegards,\n-- \nPaolo\nhttp://paolo.ciarrocchi.googlepages.com/\nhttp://mypage.vodafone.it/\n"}]}