{"thread":{"id":"32836","subject":"importing two different trees into a fresh git repo","startedAt":"2013-02-05T21:46:09Z","lastAt":"2013-02-06T09:07:32Z","messageCount":4,"participants":["Constantine A. Murenin","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"208768","messageId":"CAPKkNb6+ojb+uvBW+AkhGrhjR85LrJEbmR0KmvaKYb2Cj5Aa4g@mail.gmail.com","threadId":"32836","inReplyTo":null,"subject":"importing two different trees into a fresh git repo","fromName":"Constantine A. Murenin","fromEmail":"mureninc@gmail.com","sentAt":"2013-02-05T21:46:09Z","receivedAt":"2013-02-05T21:46:09Z","isPatch":false,"sender":{"key":"mureninc@gmail.com","avatar":null},"body":"Hi,\n\nI have two distinct trees that were not managed by any RCS, and I'd\nlike to import them into a single repository into two separate orphan\nbranches, then make sense of what's in there, merge, and unify into\n'master'.\n\n(To give some context, it's /etc/nginx config files from nginx/1.0.12\non Debian 6 and nginx/1.2.2 on OpenBSD 5.2.)\n\nI've encountered two problems so far:\n\n0. After initialising the repository, I was unable to `git checkout\n--orphan Debian-6.0.4-nginx-1.0.12` -- presumably it doesn't work when\nthe repo is empty?  This sounds like a bug or an artefact of\nimplementation.  I presume this can be worked around by committing\ninto master instead, and then doing `git checkout -b\nDebian-6.0.4-nginx-1.0.12`, and then force-fixing the master somehow\nlater on.\n\n1. After making a mistake on my first commit (my first commit into\nOpenBSD-5.2-nginx-1.2.2 orphan branch ended up including a directory\nfrom master by mistake), I am now unable to rebase and \"fixup\" the\nchanges -- `git rebase --interactive HEAD~2` doesn't work, which, from\none perspective, makes perfect sense (indeed there's no prior\nrevision), but, from another, it's not immediately obvious how to\nquickly work around it.\n\nAny suggestions?\n\nIt would seem like making some kind of a dummy first commit into\nmaster would be the best workaround for both of these problems.  Is\nthat basically the suggested approach?\n\nBest regards,\nConstantine.\n"},{"id":"208773","messageId":"7va9riqtro.fsf@alter.siamese.dyndns.org","threadId":"32836","inReplyTo":"CAPKkNb6+ojb+uvBW+AkhGrhjR85LrJEbmR0KmvaKYb2Cj5Aa4g@mail.gmail.com","subject":"Re: importing two different trees into a fresh git repo","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-05T22:29:31Z","receivedAt":"2013-02-05T22:29:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Constantine A. Murenin\" <mureninc@gmail.com> writes:\n\n> I have two distinct trees that were not managed by any RCS, and I'd\n> like to import them into a single repository into two separate orphan\n> branches, then make sense of what's in there, merge, and unify into\n> 'master'.\n>\n> (To give some context, it's /etc/nginx config files from nginx/1.0.12\n> on Debian 6 and nginx/1.2.2 on OpenBSD 5.2.)\n\nAs these come from two totally separate sources, I'd find it more\nnatural to do two repositories, deb-nginx-conf and obsd-nginx-conf,\neach with one commit and then pull one into the other (or pull both\nto master-nginx-conf if you really wanted to), to me.\n"},{"id":"208780","messageId":"CAPKkNb494MvSETOS+1R+dbxKzcwZhbz7jEB-W=z-XuLBKDJWeA@mail.gmail.com","threadId":"32836","inReplyTo":"7va9riqtro.fsf@alter.siamese.dyndns.org","subject":"Re: importing two different trees into a fresh git repo","fromName":"Constantine A. Murenin","fromEmail":"mureninc@gmail.com","sentAt":"2013-02-06T00:35:54Z","receivedAt":"2013-02-06T00:35:54Z","isPatch":false,"sender":{"key":"mureninc@gmail.com","avatar":null},"body":"On 5 February 2013 14:29, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Constantine A. Murenin\" <mureninc@gmail.com> writes:\n>\n>> I have two distinct trees that were not managed by any RCS, and I'd\n>> like to import them into a single repository into two separate orphan\n>> branches, then make sense of what's in there, merge, and unify into\n>> 'master'.\n>>\n>> (To give some context, it's /etc/nginx config files from nginx/1.0.12\n>> on Debian 6 and nginx/1.2.2 on OpenBSD 5.2.)\n>\n> As these come from two totally separate sources, I'd find it more\n> natural to do two repositories, deb-nginx-conf and obsd-nginx-conf,\n> each with one commit and then pull one into the other (or pull both\n> to master-nginx-conf if you really wanted to), to me.\n\nYeah, I guess it might be more of a git-style to have two/three\nseparate repositories here.  (The sources are just a couple of files,\nso I think my specific example still calls for merely two orphan\nbranches.)\n\nStill, is it really expected that you can't create an orphan branch in\nan empty repository?  On the outside, this sounds like a rather benign\nbug.\n\nC.\n"},{"id":"208788","messageId":"20130206090731.GA6452@sigill.intra.peff.net","threadId":"32836","inReplyTo":"CAPKkNb6+ojb+uvBW+AkhGrhjR85LrJEbmR0KmvaKYb2Cj5Aa4g@mail.gmail.com","subject":"Re: importing two different trees into a fresh git repo","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-02-06T09:07:32Z","receivedAt":"2013-02-06T09:07:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 05, 2013 at 01:46:09PM -0800, Constantine A. Murenin wrote:\n\n> I've encountered two problems so far:\n> \n> 0. After initialising the repository, I was unable to `git checkout\n> --orphan Debian-6.0.4-nginx-1.0.12` -- presumably it doesn't work when\n> the repo is empty?  This sounds like a bug or an artefact of\n> implementation.  I presume this can be worked around by committing\n> into master instead, and then doing `git checkout -b\n> Debian-6.0.4-nginx-1.0.12`, and then force-fixing the master somehow\n> later on.\n\nWhat version of git are you using? Using both \"-b\" and \"--orphan\" from a\nnon-existing branch used to be broken, but was fixed by abe1998 (git\ncheckout -b: allow switching out of an unborn branch, 2012-01-30), which\nfirst appeared in git v1.7.9.2.\n\n> 1. After making a mistake on my first commit (my first commit into\n> OpenBSD-5.2-nginx-1.2.2 orphan branch ended up including a directory\n> from master by mistake), I am now unable to rebase and \"fixup\" the\n> changes -- `git rebase --interactive HEAD~2` doesn't work, which, from\n> one perspective, makes perfect sense (indeed there's no prior\n> revision), but, from another, it's not immediately obvious how to\n> quickly work around it.\n\nYou cannot ask to rebase onto HEAD~2 because it does not exist (I'm assuming\nfrom your description that HEAD~1 is the root of your repository). But\nyou can use the \"--root\" flag to ask git to rebase all the way down to\nthe roots, like:\n\n  git rebase -i --root\n\nHowever, note that older versions of git do not support using \"--root\"\nwith \"-i\". The first usable version is v1.7.12.\n\n-Peff\n"}]}