{"thread":{"id":"22480","subject":"How can I create a commit without a parent?","startedAt":"2010-02-02T08:00:26Z","lastAt":"2010-02-02T16:40:53Z","messageCount":5,"participants":["Ron Garret","Junio C Hamano","Jakub Narebski","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133329","messageId":"ron1-5383E3.00002602022010@news.gmane.org","threadId":"22480","inReplyTo":null,"subject":"How can I create a commit without a parent?","fromName":"Ron Garret","fromEmail":"ron1@flownet.com","sentAt":"2010-02-02T08:00:26Z","receivedAt":"2010-02-02T08:00:26Z","isPatch":false,"sender":{"key":"ron1@flownet.com","avatar":null},"body":"SLSIA.  git commit-tree insists on having at least one parent commit at \nthe command line.  From reverse-engineering it seems like I could do it \nby setting .git/HEAD to 'ref: refs/heads/some-nonexistent-branch' but \nmucking with HEAD directly like that feels kinda scary.\n\nThanks,\nrg\n"},{"id":"133332","messageId":"7vwryw6p16.fsf@alter.siamese.dyndns.org","threadId":"22480","inReplyTo":"ron1-5383E3.00002602022010@news.gmane.org","subject":"Re: How can I create a commit without a parent?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-02T08:05:25Z","receivedAt":"2010-02-02T08:05:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ron Garret <ron1@flownet.com> writes:\n\n> git commit-tree insists on having at least one parent commit at \n> the command line.\n\nIncorrect.  \"git commit\" might but \"git commit-tree\" does.  Perhaps you\nare forgetting that the first object name is a tree to be wrapped.\n\nA short answer is that you don't create a root commit twice in a single\nrepository, period.  Your repository _may_ be end up with more than one\nroot but that typically is due to you fetching unrelated histories from\ndifferent repositories, each created its own root.\n"},{"id":"133334","messageId":"ron1-2FA457.00192402022010@news.gmane.org","threadId":"22480","inReplyTo":"7vwryw6p16.fsf@alter.siamese.dyndns.org","subject":"Re: How can I create a commit without a parent?","fromName":"Ron Garret","fromEmail":"ron1@flownet.com","sentAt":"2010-02-02T08:19:24Z","receivedAt":"2010-02-02T08:19:24Z","isPatch":false,"sender":{"key":"ron1@flownet.com","avatar":null},"body":"In article <7vwryw6p16.fsf@alter.siamese.dyndns.org>,\n Junio C Hamano <gitster@pobox.com> wrote:\n\n> Ron Garret <ron1@flownet.com> writes:\n> \n> > git commit-tree insists on having at least one parent commit at \n> > the command line.\n> \n> Incorrect.  \"git commit\" might but \"git commit-tree\" does.  Perhaps you\n> are forgetting that the first object name is a tree to be wrapped.\n\nNo, I didn't forget that.  I forgot to omit the -p flag.  Doh!\n\n> A short answer is that you don't create a root commit twice in a single\n> repository, period.\n\nWhy not?  I could easily create an empty root commit and multiple \nbranches off that.  (Maybe that's a better way to go.)  What would be \nthe difference?\n\nrg\n"},{"id":"133358","messageId":"m3zl3radgl.fsf@localhost.localdomain","threadId":"22480","inReplyTo":"ron1-5383E3.00002602022010@news.gmane.org","subject":"Re: How can I create a commit without a parent?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-02-02T15:02:33Z","receivedAt":"2010-02-02T15:02:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Ron Garret <ron1@flownet.com> writes:\n\n> SLSIA.  git commit-tree insists on having at least one parent commit at \n> the command line.  From reverse-engineering it seems like I could do it \n> by setting .git/HEAD to 'ref: refs/heads/some-nonexistent-branch' but \n> mucking with HEAD directly like that feels kinda scary.\n\nYou have git-symbolic-ref to set HEAD directly (don't forget to remove\nindex).  \n\nOr you can set up / initialize separate (new) repository, create\ncommit there and then pull this new repository into current one.\n\n\nP.S. Creating new root (parentless) commit isn't something that you do\non purpose, usually.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"133366","messageId":"76718491002020840y16d62fb5qc4f6c51602dac94f@mail.gmail.com","threadId":"22480","inReplyTo":"ron1-5383E3.00002602022010@news.gmane.org","subject":"Re: How can I create a commit without a parent?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-02T16:40:53Z","receivedAt":"2010-02-02T16:40:53Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Feb 2, 2010 at 3:00 AM, Ron Garret <ron1@flownet.com> wrote:\n> SLSIA.  git commit-tree insists on having at least one parent commit at\n> the command line.  From reverse-engineering it seems like I could do it\n> by setting .git/HEAD to 'ref: refs/heads/some-nonexistent-branch' but\n> mucking with HEAD directly like that feels kinda scary.\n\nI guess you're looking to do it with plumbing, but with porcelain the\nway I'd do it is:\n\n$ git init foo\n$ git init bar\n$ cd bar\n$ git commit --allow-empty -m \"empty bar root commit\"\n$ cd ../foo\n$ git commit --allow-empty -m \"empty foo root commit\"\n$ git fetch ../bar master:bar\n\nj.\n"}]}