{"thread":{"id":"20157","subject":"how to start with non-master branch?","startedAt":"2009-07-19T12:53:32Z","lastAt":"2009-07-19T18:26:45Z","messageCount":5,"participants":["Rustom Mody","Dirk Süsserott","Sean Estabrooks","Charles Bailey","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"118262","messageId":"f46c52560907190553x4e21ffbdn6d55c43f2d6b08ad@mail.gmail.com","threadId":"20157","inReplyTo":null,"subject":"how to start with non-master branch?","fromName":"Rustom Mody","fromEmail":"rustompmody@gmail.com","sentAt":"2009-07-19T12:53:32Z","receivedAt":"2009-07-19T12:53:32Z","isPatch":false,"sender":{"key":"rustompmody@gmail.com","avatar":null},"body":"I want my first commit to be on a non-master branch.\nSo after the git init I do\n$ git checkout -b newbranch\n\nI get\nfatal: You are on a branch yet to be born\n\nOf course I can get by with making the first commit on master and then\nswitching.\n\nBut wondering if I am missing something basic?\n"},{"id":"118265","messageId":"4A634616.9020302@dirk.my1.cc","threadId":"20157","inReplyTo":"f46c52560907190553x4e21ffbdn6d55c43f2d6b08ad@mail.gmail.com","subject":"Re: how to start with non-master branch?","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2009-07-19T16:13:10Z","receivedAt":"2009-07-19T16:13:10Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 19.07.2009 14:53 schrieb Rustom Mody:\n> I want my first commit to be on a non-master branch.\n> So after the git init I do\n> $ git checkout -b newbranch\n> \n> I get\n> fatal: You are on a branch yet to be born\n> \n> Of course I can get by with making the first commit on master and then\n> switching.\n> \n> But wondering if I am missing something basic?\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\nWhat about renaming the \"initial master\", i.e.:\ngit init\ngit add .\ngit commit -m \"intial checkin\"\ngit branch -m non-master-branch\n\nand later adding a master just as any other branch, i.e.\ngit checkout -b master\n\nUnfortunately renaming doesn't work before the first commit, I got an \nerror similar to yours.\n\nI think the name \"master\" is just a convention and there's nothing \nspecial about that branch. Could've been called \"main\" or sth. as well \nwhen Linus invented it.\n\nDirk\n"},{"id":"118267","messageId":"BLU0-SMTP89B66EA462C93B0D1943F6AE1C0@phx.gbl","threadId":"20157","inReplyTo":"f46c52560907190553x4e21ffbdn6d55c43f2d6b08ad@mail.gmail.com","subject":"Re: how to start with non-master branch?","fromName":"Sean Estabrooks","fromEmail":"seanlkml@sympatico.ca","sentAt":"2009-07-19T16:19:29Z","receivedAt":"2009-07-19T16:19:29Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Sun, 19 Jul 2009 18:23:32 +0530\nRustom Mody <rustompmody@gmail.com> wrote:\n\nHi Rustom,\n\n> I want my first commit to be on a non-master branch.\n> So after the git init I do\n> $ git checkout -b newbranch\n> \n> I get\n> fatal: You are on a branch yet to be born\n\nNo branches exist in a new repository that you've just init'ed.  If you run\n\"git branch\" you'll see that no branches are listed.  You must make an\ninitial commit before a branch will be \"born\".   Since \"git checkout\"\nneeds you to supply a branch/commit to operate, you can't use it to create\nthe first branch in a repo.\n\nWhen you make the initial commit in a repo the HEAD reference will\ndetermine which branch is created.   So the following ugly looking\ncommand will allow you to change the name to something other than \nmaster before making your first commit:\n\n\t$ git symbolic-ref HEAD refs/heads/newbranch\n\n> Of course I can get by with making the first commit on master and then\n> switching.\n\nThat is probably the simplest thing to do, rename master after the initial\ncommit:\n\n\t$ git commit -m \"initial commit\"\n\t$ git branch -m newbranch\n\nHTH,\nSean\n"},{"id":"118268","messageId":"20090719174441.GA14556@hashpling.org","threadId":"20157","inReplyTo":"f46c52560907190553x4e21ffbdn6d55c43f2d6b08ad@mail.gmail.com","subject":"Re: how to start with non-master branch?","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-07-19T17:44:41Z","receivedAt":"2009-07-19T17:44:41Z","isPatch":false,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Sun, Jul 19, 2009 at 06:23:32PM +0530, Rustom Mody wrote:\n> I want my first commit to be on a non-master branch.\n> So after the git init I do\n> $ git checkout -b newbranch\n> \n> I get\n> fatal: You are on a branch yet to be born\n> \n> Of course I can get by with making the first commit on master and then\n> switching.\n> \n> But wondering if I am missing something basic?\n\nThe problem with git checkout -b newbranch is that it tries to create\na new branch based on your current HEAD. As you have no commits, your\nHEAD doesn't point at a commit ant this can't work. To change the name\nof your current branch before you've made any commits, you can use the\nsymbolic-ref command to update your HEAD to point to a differently\nnamed branch (that also doesn't yet exist). Try this:\n\ngit symbolic-ref HEAD refs/heads/non-master\n\nand then carry on adding and committing as before.\n\nCharles.\n\n-- \nCharles Bailey\nhttp://ccgi.hashpling.plus.com/blog/\n"},{"id":"118270","messageId":"4A636565.2000703@drmicha.warpmail.net","threadId":"20157","inReplyTo":"f46c52560907190553x4e21ffbdn6d55c43f2d6b08ad@mail.gmail.com","subject":"Re: how to start with non-master branch?","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-07-19T18:26:45Z","receivedAt":"2009-07-19T18:26:45Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Rustom Mody venit, vidit, dixit 19.07.2009 14:53:\n> I want my first commit to be on a non-master branch.\n> So after the git init I do\n> $ git checkout -b newbranch\n> \n> I get\n> fatal: You are on a branch yet to be born\n> \n> Of course I can get by with making the first commit on master and then\n> switching.\n> \n> But wondering if I am missing something basic?\n\nYou can do\n\ngit symbolic-ref HEAD refs/heads/newbranch\n\nand your first commit will be to that branch. (checkout as above tries\nto branch off the non-existing branch master.)\n\nCheers,\nMichael\n"}]}