{"thread":{"id":"33973","subject":"git init doesn't create master branch","startedAt":"2013-05-29T12:47:28Z","lastAt":"2013-05-29T18:37:28Z","messageCount":8,"participants":["Ákos, Tajti","Matthieu Moy","Ramkumar Ramachandra","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"218814","messageId":"51A5F8E0.8060906@intland.com","threadId":"33973","inReplyTo":null,"subject":"git init doesn't create master branch","fromName":"Ákos, Tajti","fromEmail":"akos.tajti@intland.com","sentAt":"2013-05-29T12:47:28Z","receivedAt":"2013-05-29T12:47:28Z","isPatch":false,"sender":{"key":"akos.tajti@intland.com","avatar":null},"body":"Dear List,\n\nthe manual of git init says: \"An initial HEAD file that references the \nHEAD of the master branch is also created.\"\n\nHowever, after creating the repository using git init there's no master \nbranch. How can make sure that master is created?\n\nThanks in advance,\nÁkos Tajti\n"},{"id":"218815","messageId":"vpqk3migdb1.fsf@anie.imag.fr","threadId":"33973","inReplyTo":"51A5F8E0.8060906@intland.com","subject":"Re: git init doesn't create master branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-05-29T12:50:42Z","receivedAt":"2013-05-29T12:50:42Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Ákos, Tajti\" <akos.tajti@intland.com> writes:\n\n> Dear List,\n>\n> the manual of git init says: \"An initial HEAD file that references the\n> HEAD of the master branch is also created.\"\n>\n> However, after creating the repository using git init there's no\n> master branch.\n\nRight, but HEAD still points to it ;-). We sometimes call this an\n\"unborn branch\".\n\n> How can make sure that master is created?\n\nIt will be created when you do the first commit. If you insist in having\nmaster created before you actually start working, you can run:\n\n  git commit -m \"Initial empty commit\" --allow-empty\n\nRight after \"git init\".\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"218817","messageId":"CALkWK0m=m89QcnMNg9gEVeb7ZHSRd7ZMcL+y8gYuzn8YCTsSYw@mail.gmail.com","threadId":"33973","inReplyTo":"vpqk3migdb1.fsf@anie.imag.fr","subject":"Re: git init doesn't create master branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-05-29T12:54:43Z","receivedAt":"2013-05-29T12:54:43Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Matthieu Moy wrote:\n>> the manual of git init says: \"An initial HEAD file that references the\n>> HEAD of the master branch is also created.\"\n>>\n>> However, after creating the repository using git init there's no\n>> master branch.\n>\n> Right, but HEAD still points to it ;-). We sometimes call this an\n> \"unborn branch\".\n\nRight.  Let me also add that our prompt has support for this; on an\nunborn branch, my prompt looks like:\n\nartagnon|master#:/tmp/foo$\n               ^\n\t       the # indicates unborn branch\n\nPlease consider using contrib/completion/git-prompt.sh to make your life easier.\n"},{"id":"218818","messageId":"51A5FC17.8000608@intland.com","threadId":"33973","inReplyTo":"CALkWK0m=m89QcnMNg9gEVeb7ZHSRd7ZMcL+y8gYuzn8YCTsSYw@mail.gmail.com","subject":"Re: git init doesn't create master branch","fromName":"Ákos, Tajti","fromEmail":"akos.tajti@intland.com","sentAt":"2013-05-29T13:01:11Z","receivedAt":"2013-05-29T13:01:11Z","isPatch":false,"sender":{"key":"akos.tajti@intland.com","avatar":null},"body":"Thanks for clarifying this thing for me! I don't really insist on having \na master branch it's just that I tried to pull from a repository bundle \nand I got this error message:\n\n\"Cannot merge multiple branches into empty head\"\n\nThe command was:\n\ngit pull ../dump.dmp refs/heads/*:refs/heads/*\n\nIs this a better way of doing this?\n\nThanks,\nÁkos\n\n2013.05.29. 14:54 keltezéssel, Ramkumar Ramachandra írta:\n> Matthieu Moy wrote:\n>>> the manual of git init says: \"An initial HEAD file that references the\n>>> HEAD of the master branch is also created.\"\n>>>\n>>> However, after creating the repository using git init there's no\n>>> master branch.\n>> Right, but HEAD still points to it ;-). We sometimes call this an\n>> \"unborn branch\".\n> Right.  Let me also add that our prompt has support for this; on an\n> unborn branch, my prompt looks like:\n>\n> artagnon|master#:/tmp/foo$\n>                 ^\n> \t       the # indicates unborn branch\n>\n> Please consider using contrib/completion/git-prompt.sh to make your life easier.\n"},{"id":"218819","messageId":"vpqbo7udjcy.fsf@anie.imag.fr","threadId":"33973","inReplyTo":"51A5FC17.8000608@intland.com","subject":"Re: git init doesn't create master branch","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-05-29T13:08:13Z","receivedAt":"2013-05-29T13:08:13Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Ákos, Tajti\" <akos.tajti@intland.com> writes:\n\n> The command was:\n>\n> git pull ../dump.dmp refs/heads/*:refs/heads/*\n\n\"git pull\" does internally a \"git fetch\" followed by a \"git merge\".\n\nIf you try to pull several branches at the same time, it means you want\nto merge all of them together (octopus merge), which probably isn't what\nyou're trying to do. You probably want just a \"git fetch\", or specify\nonly one branch to pull.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"218822","messageId":"51A6009E.8020503@intland.com","threadId":"33973","inReplyTo":"vpqbo7udjcy.fsf@anie.imag.fr","subject":"Re: git init doesn't create master branch","fromName":"Ákos, Tajti","fromEmail":"akos.tajti@intland.com","sentAt":"2013-05-29T13:20:30Z","receivedAt":"2013-05-29T13:20:30Z","isPatch":false,"sender":{"key":"akos.tajti@intland.com","avatar":null},"body":"Thanks! I ill try using fetch.\n\nÁkos\n\n2013.05.29. 15:08 keltezéssel, Matthieu Moy írta:\n> \"Ákos, Tajti\" <akos.tajti@intland.com> writes:\n>\n>> The command was:\n>>\n>> git pull ../dump.dmp refs/heads/*:refs/heads/*\n> \"git pull\" does internally a \"git fetch\" followed by a \"git merge\".\n>\n> If you try to pull several branches at the same time, it means you want\n> to merge all of them together (octopus merge), which probably isn't what\n> you're trying to do. You probably want just a \"git fetch\", or specify\n> only one branch to pull.\n>\n"},{"id":"218823","messageId":"CALkWK0nLJn2EDy9KO+Qp3sHhxgyKQag-575srq5ztuu5LgsmyA@mail.gmail.com","threadId":"33973","inReplyTo":"51A5FC17.8000608@intland.com","subject":"Re: git init doesn't create master branch","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-05-29T13:20:39Z","receivedAt":"2013-05-29T13:20:39Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"\"Ákos, Tajti\" wrote:\n> \"Cannot merge multiple branches into empty head\"\n>\n> The command was:\n>\n> git pull ../dump.dmp refs/heads/*:refs/heads/*\n>\n> Is this a better way of doing this?\n\npull runs a fetch, which updated .git/FETCH_HEAD.  Now, if\n.git/FETCH_HEAD has just one branch (and other not-for-merge entries),\nthere's no problem.  We just run update-ref HEAD, and get it to point\nto the sole branch that was fetched.  If your fetch fetches multiple\nbranches, and you have a real branch (not \"unborn\") with\nbranch.<name>.merge set, we know which one of those branches to merge\nin.\n\nNow, what you have is a fetch which fetches multiple branches, and\nyou're trying to merge that into a non-existent HEAD (or unborn\nbranch).  There is ambiguity and arguably no \"right\" thing to do,\nwhich is why git complains.  I'm not sure if it's possible to argue\ndifferently and patch git-pull.sh for your usecase.\n\nThere are many possible solutions to the problem, depending on what\nyou want.  The simplest I can suggest is: ignore the error for that\ncommand and run git reset --hard.\n"},{"id":"218874","messageId":"7va9ndtyxj.fsf@alter.siamese.dyndns.org","threadId":"33973","inReplyTo":"51A5FC17.8000608@intland.com","subject":"Re: git init doesn't create master branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-29T18:37:28Z","receivedAt":"2013-05-29T18:37:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Ákos, Tajti\" <akos.tajti@intland.com> writes:\n\n> Thanks for clarifying this thing for me! I don't really insist on\n> having a master branch it's just that I tried to pull from a\n> repository bundle and I got this error message:\n>\n> \"Cannot merge multiple branches into empty head\"\n>\n> The command was:\n>\n> git pull ../dump.dmp refs/heads/*:refs/heads/*\n>\n> Is this a better way of doing this?\n\nYou are not trying to merge all branches contained in the dump, so\n\"pull\" is a wrong thing to use here.\n\n    $ git fetch --update-head-ok ../dump.dmp refs/heads/*:refs/heads/*\n\nwould be one way.  Or you could just use the dumpfile as if it were\na normal remote and say (without running \"git init\")\n\n    $ git clone dump.dmp undump\n\nto extract it in a new directory \"undump\" (this may require your\ndumpfile created with HEAD, though).\n"}]}