{"thread":{"id":"15058","subject":"git clone operation","startedAt":"2008-08-17T18:44:43Z","lastAt":"2008-08-20T02:27:18Z","messageCount":5,"participants":["Mike Gant","Jakub Narebski","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"87451","messageId":"20080817184443.GA11782@mg1.gantsfort.com","threadId":"15058","inReplyTo":null,"subject":"git clone operation","fromName":"Mike Gant","fromEmail":"mwgant@gmail.com","sentAt":"2008-08-17T18:44:43Z","receivedAt":"2008-08-17T18:44:43Z","isPatch":false,"sender":{"key":"mwgant@gmail.com","avatar":null},"body":"I'm trying to understand git-clone and what to expect when I clone a\nrepository. Disclaimer, I am a newbie :).\n\nAssume I have a repo with the following branches:\n\n  cpu-intfc\n  gige_mux\n  improve-build\n  main-devel\n* master\n\nAccording to the man page, git-clone \"creates and checks out an initial\nbranch equal to the cloned repository's currently active branch.\"\n\nSo, when I clone this repo and run 'git-branch -a' I will have the\nfollowing:\n\n  origin/HEAD\n  origin/cpu-intfc\n  origin/gige_mux\n  origin/improve-build\n  origin/main-devel\n  origin/master\n* master\n\nAll the origin/* branches are remote.\n\nAnd, .git/refs/remotes/origin/HEAD is, \n\n$ cat .git/refs/remotes/origin/HEAD\nref: refs/remotes/origin/master\n\nSo far, this makes sense to me.\n\nNow, let's say that I am working in the cpu-intfc branch of the original\nrepository and I clone the repository.\n\nRunning git-branch -a returns the following\n\n  origin/HEAD\n  origin/cpu-intfc\n  origin/gige_mux\n  origin/improve-build\n  origin/main-devel\n  origin/master\n* cpu-intfc\n\nAnd this,\n\n$ cat .git/refs/remotes/origin/HEAD\nref: refs/remotes/origin/cpu-intfc\n\nI was expecting to have a local branch named master (that is equal to\nthe remote branch origin/cpu-intfc) instead of cpu-intfc. Am I wrong to\nexpect this? Also, as a newbie user, it seems odd that I cannot specify\nwhich branch of repo that I am cloning should be the default (master)\nbranch of the cloned repo? To put it another way, when cloning a repo I\nhave no way of controlling which branch I get as the default. It just\nhappens to depend on which branch the developer is working in at the\ntime I clone.  I've read through the man-page and there doesn't seem to\nbe any way around this.\n\nI realize that I can create a new local branch that is based off the\ndesired branch:\n\n$ git-checkout -b master origin/master\n\nIs this the accepted method for obtaining the desired branch?\n\n\nThanks,\nMike\n"},{"id":"87452","messageId":"m3wsifsawl.fsf@localhost.localdomain","threadId":"15058","inReplyTo":"20080817184443.GA11782@mg1.gantsfort.com","subject":"Re: git clone operation","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-08-17T19:23:57Z","receivedAt":"2008-08-17T19:23:57Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Mike Gant <mwgant@gmail.com> writes:\n\n> I'm trying to understand git-clone and what to expect when I clone a\n> repository. Disclaimer, I am a newbie :).\n[...]\n\n> According to the man page, git-clone \"creates and checks out an initial\n> branch equal to the cloned repository's currently active branch.\"\n[...]\n\n> Now, let's say that I am working in the cpu-intfc branch of the original\n> repository and I clone the repository.\n> \n> Running git-branch -a returns the following\n> \n>   origin/HEAD\n>   origin/cpu-intfc\n>   origin/gige_mux\n>   origin/improve-build\n>   origin/main-devel\n>   origin/master\n> * cpu-intfc\n> \n> And this,\n> \n> $ cat .git/refs/remotes/origin/HEAD\n> ref: refs/remotes/origin/cpu-intfc\n> \n> I was expecting to have a local branch named master (that is equal to\n> the remote branch origin/cpu-intfc) instead of cpu-intfc. Am I wrong to\n> expect this? Also, as a newbie user, it seems odd that I cannot specify\n> which branch of repo that I am cloning should be the default (master)\n> branch of the cloned repo? To put it another way, when cloning a repo I\n> have no way of controlling which branch I get as the default. It just\n> happens to depend on which branch the developer is working in at the\n> time I clone.  I've read through the man-page and there doesn't seem to\n> be any way around this.\n\nCurrently the situation is a bit strange, because while git-remote\nsupports selecting which branch is meant to be remote-tracking master\nbranch via '-m <master>' option to \"add\" subcommand (setting\norigin/HEAD symref), git-clone which is init + remote + fetch + some\nbookkeeping and shortcuts doesn't.\n\nBoth commands are now built-in.\n\n> I realize that I can create a new local branch that is based off the\n> desired branch:\n> \n> $ git-checkout -b master origin/master\n> \n> Is this the accepted method for obtaining the desired branch?\n\nYou can use (with new anough Git)\n\n  $ git checkout --track -b master origin/master\n\nto setup repository in such way that \"git pull\" on 'master'\nwould know that it is meant to fetch from 'origin' and merge\n'origin/master'.\n\nIn upcoming 1.6.1 it would be enough to use\n\n  $ git checkout --track origin/master\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"87453","messageId":"20080817193833.GA29469@atjola.homenet","threadId":"15058","inReplyTo":"m3wsifsawl.fsf@localhost.localdomain","subject":"Re: git clone operation","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-08-17T19:38:33Z","receivedAt":"2008-08-17T19:38:33Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.08.17 12:23:57 -0700, Jakub Narebski wrote:\n> Mike Gant <mwgant@gmail.com> writes:\n> > I realize that I can create a new local branch that is based off the\n> > desired branch:\n> > \n> > $ git-checkout -b master origin/master\n> > \n> > Is this the accepted method for obtaining the desired branch?\n> \n> You can use (with new anough Git)\n> \n>   $ git checkout --track -b master origin/master\n> \n> to setup repository in such way that \"git pull\" on 'master'\n> would know that it is meant to fetch from 'origin' and merge\n> 'origin/master'.\n\nbranch.autosetupmerge is set to true by default, so for remote branches\n--track is the default anyway (since 1.5.5 IIRC). So only an old enough\ngit would actually require --track, unless you changed the config ;-)\n\nBjörn\n"},{"id":"87782","messageId":"8f282e3b0808191923w18001cc6sef828d94b35e40c6@mail.gmail.com","threadId":"15058","inReplyTo":"20080817193833.GA29469@atjola.homenet","subject":"Re: git clone operation","fromName":"Mike Gant","fromEmail":"mwgant@gmail.com","sentAt":"2008-08-20T02:23:49Z","receivedAt":"2008-08-20T02:23:49Z","isPatch":false,"sender":{"key":"mwgant@gmail.com","avatar":null},"body":"On Sun, Aug 17, 2008 at 1:38 PM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:\n> On 2008.08.17 12:23:57 -0700, Jakub Narebski wrote:\n>> Mike Gant <mwgant@gmail.com> writes:\n>> > I realize that I can create a new local branch that is based off the\n>> > desired branch:\n>> >\n>> > $ git-checkout -b master origin/master\n>> >\n>> > Is this the accepted method for obtaining the desired branch?\n>>\n>> You can use (with new anough Git)\n>>\n>>   $ git checkout --track -b master origin/master\n>>\n>> to setup repository in such way that \"git pull\" on 'master'\n>> would know that it is meant to fetch from 'origin' and merge\n>> 'origin/master'.\n>\n> branch.autosetupmerge is set to true by default, so for remote branches\n> --track is the default anyway (since 1.5.5 IIRC). So only an old enough\n> git would actually require --track, unless you changed the config ;-)\n>\n> Björn\n>\n\nThanks for your responses. I appreciate you guys taking the time to answer.\n\nAfter thinking about this, I still don't understand when I clone a\nrepo why I will\nget the equivalent of whatever branch is active at the time of cloning? What\nwas the process that led to this design decision?\n\nSo that also got me thinking about work flows with git. Because of the way clone\nworks it seems that you wouldn't want someone to clone your every day \"work\"\nrepository? So do developers generally have a separate repository that they push\nto and others can clone? This repository may have only a 'master' branch (but\nprobably others I seem to recall Junio describing other branches in the main git\nrepository). Is this a 'normal' work flow?\n\nThanks,\nMike Gant\n"},{"id":"87783","messageId":"8f282e3b0808191927t7c202a2dvdff678bcec60d87f@mail.gmail.com","threadId":"15058","inReplyTo":"8f282e3b0808191923w18001cc6sef828d94b35e40c6@mail.gmail.com","subject":"Re: git clone operation","fromName":"Mike Gant","fromEmail":"mwgant@gmail.com","sentAt":"2008-08-20T02:27:18Z","receivedAt":"2008-08-20T02:27:18Z","isPatch":false,"sender":{"key":"mwgant@gmail.com","avatar":null},"body":"> Thanks for your responses. I appreciate you guys taking the time to answer.\n>\n> After thinking about this, I still don't understand when I clone a\n> repo why I will\n> get the equivalent of whatever branch is active at the time of cloning? What\n> was the process that led to this design decision?\n>\n> So that also got me thinking about work flows with git. Because of the way clone\n> works it seems that you wouldn't want someone to clone your every day \"work\"\n> repository? So do developers generally have a separate repository that they push\n> to and others can clone? This repository may have only a 'master' branch (but\n> probably others I seem to recall Junio describing other branches in the main git\n> repository). Is this a 'normal' work flow?\n>\n> Thanks,\n> Mike Gant\n>\n\nAlso, I meant to add if the above work flow is the git way of\ndevelopment, is this\nthe purpose of a bare repository?\n"}]}