{"thread":{"id":"15697","subject":"strange \"git clone\" behavior wrt an active branch","startedAt":"2008-09-28T12:05:46Z","lastAt":"2008-09-28T19:43:11Z","messageCount":4,"participants":["Leo Razoumov","Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"91788","messageId":"ee2a733e0809280505n69f62e0fy89667c175bcc16c@mail.gmail.com","threadId":"15697","inReplyTo":null,"subject":"strange \"git clone\" behavior wrt an active branch","fromName":"Leo Razoumov","fromEmail":"slonik.az@gmail.com","sentAt":"2008-09-28T12:05:46Z","receivedAt":"2008-09-28T12:05:46Z","isPatch":false,"sender":{"key":"slonik.az@gmail.com","avatar":null},"body":"Hi All,\nI am using the latest stable version git-1.6.0.2.\n\nThe man page for git-clone states explicitly that \"git clone\"\n\n\" Clones a repository into a newly created directory, ...[snip]...\n  and creates and checks out an initial branch equal to the\n  cloned repository's currently active branch. \"\n\nI noticed that while my active branch \"My\" happens to point to the\nsame commit as the \"master\" the git clone will check out master\ninstead of My (currently active branch). Is it a bug?\n\nHere is the example that demontrates the problem\n\n~> mkdir tmp\n~/tmp> git init\n~/tmp> cat > txt\nsome text\n~/tmp> git add .\n~/tmp> git ci -m 'init ci'\n~/tmp> git branch -a\n* master\n~/tmp> git co -b My\n~/tmp> git branch -a\n* My\n  master\n\nNow \"My\" is my active branch in 'tmp' repo. It points to the same\ncommit as the master. Now let us clone it\n\n~/tmp> cd ..\n~> git clone tmp tmp1\n~> cd tmp1\n~/tmp1> git branch -a\n* master\n  origin/HEAD\n  origin/My\n  origin/master\n\nIn the cloned repository 'tmp1',  master branch is active. No local\ntracking branch for \"My\" was created. I think this behavior\ncontradicts the man page. Is it a bug or feature??\n\nThanks,\n--Leo--\n"},{"id":"91790","messageId":"adf1fd3d0809280537k7adffe3dte9579fe70c7f990e@mail.gmail.com","threadId":"15697","inReplyTo":"ee2a733e0809280505n69f62e0fy89667c175bcc16c@mail.gmail.com","subject":"Re: strange \"git clone\" behavior wrt an active branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2008-09-28T12:37:30Z","receivedAt":"2008-09-28T12:37:30Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:\n> Hi All,\n> I am using the latest stable version git-1.6.0.2.\n>\n> The man page for git-clone states explicitly that \"git clone\"\n>\n> \" Clones a repository into a newly created directory, ...[snip]...\n>  and creates and checks out an initial branch equal to the\n>  cloned repository's currently active branch. \"\n>\n> I noticed that while my active branch \"My\" happens to point to the\n> same commit as the \"master\" the git clone will check out master\n> instead of My (currently active branch). Is it a bug?\n>\n\nCurrently it is only guessed which is the active branch (with a\npreference for the master branch as it is the default), as the current\nprotocol does not allow tranfering the ref links:\n\n$ git ls-remote $url\n$sha1 HEAD\n$sha1 $branchname\n...\n\ninstead of:\nref: refs/heads/master HEAD\n$sha1 $branchname\n...\n\nSo, I think it is a current limitation that maybe should be documented.\n\nHTH,\nSanti\n"},{"id":"91794","messageId":"ee2a733e0809280623i30a9e298i30db2a84b8530d61@mail.gmail.com","threadId":"15697","inReplyTo":"adf1fd3d0809280537k7adffe3dte9579fe70c7f990e@mail.gmail.com","subject":"Re: strange \"git clone\" behavior wrt an active branch","fromName":"Leo Razoumov","fromEmail":"slonik.az@gmail.com","sentAt":"2008-09-28T13:23:47Z","receivedAt":"2008-09-28T13:23:47Z","isPatch":false,"sender":{"key":"slonik.az@gmail.com","avatar":null},"body":"On 9/28/08, Santi Béjar <santi@agolina.net> wrote:\n> On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:\n>  > Hi All,\n>  > I am using the latest stable version git-1.6.0.2.\n>  >\n>  > The man page for git-clone states explicitly that \"git clone\"\n>  >\n>  > \" Clones a repository into a newly created directory, ...[snip]...\n>  >  and creates and checks out an initial branch equal to the\n>  >  cloned repository's currently active branch. \"\n>  >\n>  > I noticed that while my active branch \"My\" happens to point to the\n>  > same commit as the \"master\" the git clone will check out master\n>  > instead of My (currently active branch). Is it a bug?\n>  >\n>\n>\n> Currently it is only guessed which is the active branch (with a\n>  preference for the master branch as it is the default), as the current\n>  protocol does not allow tranfering the ref links:\n\nThis is quite unfortunate design decision. There can be any number of\nlocal branches referring to the same commit. Without being able to\npick into .git/HEAD it is impossible to decide which of them is\n\"active\".\n\n--Leo--\n"},{"id":"91815","messageId":"adf1fd3d0809281243x24974ddfk3fd6ce2667ac2edc@mail.gmail.com","threadId":"15697","inReplyTo":"ee2a733e0809280623i30a9e298i30db2a84b8530d61@mail.gmail.com","subject":"Re: strange \"git clone\" behavior wrt an active branch","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2008-09-28T19:43:11Z","receivedAt":"2008-09-28T19:43:11Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Sun, Sep 28, 2008 at 3:23 PM, Leo Razoumov <slonik.az@gmail.com> wrote:\n> On 9/28/08, Santi Béjar <santi@agolina.net> wrote:\n>> On Sun, Sep 28, 2008 at 2:05 PM, Leo Razoumov <slonik.az@gmail.com> wrote:\n>>  > Hi All,\n>>  > I am using the latest stable version git-1.6.0.2.\n>>  >\n>>  > The man page for git-clone states explicitly that \"git clone\"\n>>  >\n>>  > \" Clones a repository into a newly created directory, ...[snip]...\n>>  >  and creates and checks out an initial branch equal to the\n>>  >  cloned repository's currently active branch. \"\n>>  >\n>>  > I noticed that while my active branch \"My\" happens to point to the\n>>  > same commit as the \"master\" the git clone will check out master\n>>  > instead of My (currently active branch). Is it a bug?\n>>  >\n>>\n>>\n>> Currently it is only guessed which is the active branch (with a\n>>  preference for the master branch as it is the default), as the current\n>>  protocol does not allow transferring the ref links:\n>\n> This is quite unfortunate design decision.\n\nThis is not a design decision, git has evolved, not designed. The ref\nlinks are younger than the transfer protocols.\n\n> There can be any number of\n> local branches referring to the same commit. Without being able to\n> pick into .git/HEAD it is impossible to decide which of them is\n> \"active\".\n\nI'm sure patches are welcome.\n\n>\n> --Leo--\n>\n"}]}