Re: importing two different trees into a fresh git repo
- From
Jeff King <peff@peff.net>
- Date
- Feb 6, 2013, 09:07 UTC
- Message-ID
- <20130206090731.GA6452@sigill.intra.peff.net>
- In-Reply-To
- <CAPKkNb6+ojb+uvBW+AkhGrhjR85LrJEbmR0KmvaKYb2Cj5Aa4g@mail.gmail.com>
On Tue, Feb 05, 2013 at 01:46:09PM -0800, Constantine A. Murenin wrote:
Show 9 quoted lines
> I've encountered two problems so far: > > 0. After initialising the repository, I was unable to `git checkout > --orphan Debian-6.0.4-nginx-1.0.12` -- presumably it doesn't work when > the repo is empty? This sounds like a bug or an artefact of > implementation. I presume this can be worked around by committing > into master instead, and then doing `git checkout -b > Debian-6.0.4-nginx-1.0.12`, and then force-fixing the master somehow > later on.
What version of git are you using? Using both "-b" and "--orphan" from a non-existing branch used to be broken, but was fixed by abe1998 (git checkout -b: allow switching out of an unborn branch, 2012-01-30), which first appeared in git v1.7.9.2.
Show 7 quoted lines
> 1. After making a mistake on my first commit (my first commit into > OpenBSD-5.2-nginx-1.2.2 orphan branch ended up including a directory > from master by mistake), I am now unable to rebase and "fixup" the > changes -- `git rebase --interactive HEAD~2` doesn't work, which, from > one perspective, makes perfect sense (indeed there's no prior > revision), but, from another, it's not immediately obvious how to > quickly work around it.
You cannot ask to rebase onto HEAD~2 because it does not exist (I'm assuming from your description that HEAD~1 is the root of your repository). But you can use the "--root" flag to ask git to rebase all the way down to the roots, like:
git rebase -i --root
However, note that older versions of git do not support using "--root" with "-i". The first usable version is v1.7.12.
-Peff