{"thread":{"id":"7985","subject":"Git branch bug","startedAt":"2007-05-05T16:24:03Z","lastAt":"2007-05-06T16:16:24Z","messageCount":7,"participants":["Guido Ostkamp","Johannes Schindelin","Daniel Barkalow","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"41138","messageId":"Pine.LNX.4.64.0705051823300.13988@bianca.dialin.t-online.de","threadId":"7985","inReplyTo":null,"subject":"Git branch bug","fromName":"Guido Ostkamp","fromEmail":"git@ostkamp.fastmail.fm","sentAt":"2007-05-05T16:24:03Z","receivedAt":"2007-05-05T16:24:03Z","isPatch":false,"sender":{"key":"git@ostkamp.fastmail.fm","avatar":null},"body":"Hello,\n\nI would like to report the following bug:\n\n$ mkdir test\n$ cd test\n$ git init\nInitialized empty Git repository in .git/\n$ git branch experimental\nfatal: Not a valid object name: 'master'.\n\nSo, it seems it is not possible to create a named branch on an empty \nrepository.\n\nI'm not subscribed to the list, so please keep me directly on CC for any \nreply, thanks.\n\nRegards\n\nGuido\n"},{"id":"41139","messageId":"Pine.LNX.4.64.0705051841200.4015@racer.site","threadId":"7985","inReplyTo":"Pine.LNX.4.64.0705051823300.13988@bianca.dialin.t-online.de","subject":"Re: Git branch bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-05T16:42:12Z","receivedAt":"2007-05-05T16:42:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 5 May 2007, Guido Ostkamp wrote:\n\n> $ mkdir test\n> $ cd test\n> $ git init\n> Initialized empty Git repository in .git/\n> $ git branch experimental\n> fatal: Not a valid object name: 'master'.\n> \n> So, it seems it is not possible to create a named branch on an empty\n> repository.\n\nActually, it is not possible to branch from a non-existing branch. So, \nthis is somewhat expected from my POV.\n\nCiao,\nDscho\n"},{"id":"41141","messageId":"Pine.LNX.4.64.0705051253380.28708@iabervon.org","threadId":"7985","inReplyTo":"Pine.LNX.4.64.0705051841200.4015@racer.site","subject":"Re: Git branch bug","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-05-05T17:05:51Z","receivedAt":"2007-05-05T17:05:51Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sat, 5 May 2007, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Sat, 5 May 2007, Guido Ostkamp wrote:\n> \n> > $ mkdir test\n> > $ cd test\n> > $ git init\n> > Initialized empty Git repository in .git/\n> > $ git branch experimental\n> > fatal: Not a valid object name: 'master'.\n> > \n> > So, it seems it is not possible to create a named branch on an empty\n> > repository.\n> \n> Actually, it is not possible to branch from a non-existing branch. So, \n> this is somewhat expected from my POV.\n\nThis leaves open the question of how you make your initial commit in a \nbranch that isn't master. I think the answer should be:\n\n $ git checkout -b experimental\n warning: You appear to be on a branch yet to be born.\n warning: Forcing checkout of HEAD.\n fatal: just how do you expect me to merge 0 trees?\n\nWhich should probably be:\n\n $ git checkout -b experimental\n warning: You appear to be on a branch yet to be born.\n warning: Putting you on a new branch yet to be born.\n\nAnd leaving .git/HEAD pointing to refs/heads/experimental instead of \nrefs/heads/master, with refs/heads/ still empty.\n\n $ git branch experimental\n\nShould probably give a more informative error message, but branches with \nno commits that aren't the current branch has no existance at all, so it \ncan't work to create them without switching to them.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"41148","messageId":"Pine.LNX.4.64.0705051942550.14963@bianca.dialin.t-online.de","threadId":"7985","inReplyTo":"Pine.LNX.4.64.0705051841200.4015@racer.site","subject":"Re: Git branch bug","fromName":"Guido Ostkamp","fromEmail":"git@ostkamp.fastmail.fm","sentAt":"2007-05-05T17:44:39Z","receivedAt":"2007-05-05T17:44:39Z","isPatch":false,"sender":{"key":"git@ostkamp.fastmail.fm","avatar":null},"body":"> On Sat, 5 May 2007, Guido Ostkamp wrote:\n>\n>> $ mkdir test\n>> $ cd test\n>> $ git init\n>> Initialized empty Git repository in .git/\n>> $ git branch experimental\n>> fatal: Not a valid object name: 'master'.\n>>\n>> So, it seems it is not possible to create a named branch on an empty\n>> repository.\n>\n> Actually, it is not possible to branch from a non-existing branch. So,\n> this is somewhat expected from my POV.\n\n>From a git beginners point of view, I would expect that the 'master' \nbranch is automatically created when performing the 'git init'. Why is \nthis not the case?\n\nRegards\n\nGuido\n"},{"id":"41151","messageId":"Pine.LNX.4.64.0705051954130.4015@racer.site","threadId":"7985","inReplyTo":"Pine.LNX.4.64.0705051942550.14963@bianca.dialin.t-online.de","subject":"Re: Git branch bug","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-05T17:54:20Z","receivedAt":"2007-05-05T17:54:20Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 5 May 2007, Guido Ostkamp wrote:\n\n> > On Sat, 5 May 2007, Guido Ostkamp wrote:\n> > \n> > > $ mkdir test\n> > > $ cd test\n> > > $ git init\n> > > Initialized empty Git repository in .git/\n> > > $ git branch experimental\n> > > fatal: Not a valid object name: 'master'.\n> > > \n> > > So, it seems it is not possible to create a named branch on an empty\n> > > repository.\n> > \n> > Actually, it is not possible to branch from a non-existing branch. So,\n> > this is somewhat expected from my POV.\n> \n> From a git beginners point of view, I would expect that the 'master' \n> branch is automatically created when performing the 'git init'. Why is \n> this not the case?\n\nWell, one side of the branch _is_ created. But you have to provide initial \ncontent, to make it a proper branch, from which you can actually branch \noff.\n\nHaving said that, and having read Daniels mail, I agree that this \nbehaviour should be changed, along with the behaviour of \"git checkout -b \n<branch>\" in a fresh repo.\n\nIt might be the illogical thing, to allow branching of a \nyet-to-be-initialised branch, but it does not hurt either.\n\nCiao,\nDscho\n"},{"id":"41176","messageId":"7vabwih3bd.fsf@assigned-by-dhcp.cox.net","threadId":"7985","inReplyTo":"Pine.LNX.4.64.0705051253380.28708@iabervon.org","subject":"Re: Git branch bug","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-06T06:30:14Z","receivedAt":"2007-05-06T06:30:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> This leaves open the question of how you make your initial commit in a \n> branch that isn't master. I think the answer should be:\n>\n>  $ git checkout -b experimental\n>  warning: You appear to be on a branch yet to be born.\n>  warning: Forcing checkout of HEAD.\n>  fatal: just how do you expect me to merge 0 trees?\n>\n> Which should probably be:\n>\n>  $ git checkout -b experimental\n>  warning: You appear to be on a branch yet to be born.\n>  warning: Putting you on a new branch yet to be born.\n>\n> And leaving .git/HEAD pointing to refs/heads/experimental instead of \n> refs/heads/master, with refs/heads/ still empty.\n\nWhile I agree that is probably correct, it would not be useful\nin real-life that much.  When you do not even have 'master', I\ndo not think there is much point of being able to create two\nuseless, yet-to-be-born branches.\n\nAlso, once you make a commit on 'master', you would not be able\nto create a new disconnected root with your suggestion alone.  I\nam not convinced that being able to start a disconnected root is\nuseful to begin with, but it is a different matter.  We allow\nfetching and merging from a different repository to cause\ndisconnected roots to exist in a repository anyway, so I do not\nsee any reason to disallow it either.\n\nAssuming that the ability to switch to a new yet-to-be-born\nbranch is useful, I think the right thing to do is:\n\n - Regardless of your HEAD state, you may want to have a way to\n   create a yet-to-be-born branch and switch to it.  Perhaps\n   \"git checkout -e new\" make HEAD point at refs/heads/new\n   without creating one (I picked -e randomly for \"empty\").\n\n - When you are on a yet-to-be-born branch, \"git checkout -b\n   new\" and \"git checkout -b new HEAD\" makes HEAD point at\n   refs/heads/new without creating one.  I happen to consider\n   this a not so useful corner case, but that is to make things\n   consistent.\n\n - When you are on a yet-to-be-born branch, \"git branch new\" and\n   \"git branch new HEAD\" is a nonsense operation.  We should\n   clearly state that it is nonsense (I am agreeing with the\n   last point in your message).\n"},{"id":"41218","messageId":"Pine.LNX.4.64.0705061141170.28708@iabervon.org","threadId":"7985","inReplyTo":"7vabwih3bd.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git branch bug","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-05-06T16:16:24Z","receivedAt":"2007-05-06T16:16:24Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sat, 5 May 2007, Junio C Hamano wrote:\n\n> Daniel Barkalow <barkalow@iabervon.org> writes:\n> \n> > This leaves open the question of how you make your initial commit in a \n> > branch that isn't master. I think the answer should be:\n> >\n> >  $ git checkout -b experimental\n> >  warning: You appear to be on a branch yet to be born.\n> >  warning: Forcing checkout of HEAD.\n> >  fatal: just how do you expect me to merge 0 trees?\n> >\n> > Which should probably be:\n> >\n> >  $ git checkout -b experimental\n> >  warning: You appear to be on a branch yet to be born.\n> >  warning: Putting you on a new branch yet to be born.\n> >\n> > And leaving .git/HEAD pointing to refs/heads/experimental instead of \n> > refs/heads/master, with refs/heads/ still empty.\n> \n> While I agree that is probably correct, it would not be useful\n> in real-life that much.  When you do not even have 'master', I\n> do not think there is much point of being able to create two\n> useless, yet-to-be-born branches.\n\nThe point is that you may not want to have a branch named \"master\", but \nrather want your first branch to be named something else. Your project \ncould be such that \"master\" would be a confusing term to use for a \ndefault branch. Currently, it's awkward to start a project that avoids \nthat particular name, which is what it seemed to me that the original \nposter was trying to do.\n\nI don't think it's useful to be able to switch to a new yet-to-be-born \nbranch from any other state, but I do think it's useful to be able to \nchoose what the first branch is.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"}]}