git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Constantine A. Murenin
Message 4 of 4 in “importing two different trees into a fresh git repo”
  1. Constantine A. MureninFeb 5, 2013
  2. Junio C HamanoFeb 5, 2013
  3. Constantine A. MureninFeb 6, 2013
  4. Jeff KingFeb 6, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.