git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Vajna <vmiklos@frugalware.org>
To: David Reitter <david.reitter@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How to merge by subtree while preserving history?
Date: Fri, 27 Mar 2009 08:38:47 +0100	[thread overview]
Message-ID: <20090327073847.GE27459@genesis.frugalware.org> (raw)
In-Reply-To: <A5C2B218-4E4F-4C05-959D-5B6E9C619DDB@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]

On Thu, Mar 26, 2009 at 06:59:51PM -0400, David Reitter <david.reitter@gmail.com> wrote:
> I have two separately developed projects (foo, bar) which I'd like to  
> merge; the contents of foo should, initially, go in a subdirectory of  
> bar.
> 
> I'm aware of two methods:  moving (renaming) everything within foo  
> into foo-dir, and then just pulling foo into bar.

The result of the two methods are the same.

> This works beautifully, except that the big rename causes havoc w.r.t.  
> to the files histories, i.e. git-log needs a "--follow" argument now,  
> and "diff-tree" can't track changes when given the new file name.  No  
> good.
> 
> I've also tried the method described in [1], but it seems that all  
> history is lost here (the text could point this out..)

Of course it is not lost. :)

Example:

commit f8c62880ef22b74ea6df47bb349ff0743d2a93f9
Merge: f474c52... 52b8ea9...
Author: Junio C Hamano <gitster@pobox.com>
Date:   Sun Mar 1 22:20:52 2009 -0800

    Merge git://git.kernel.org/pub/scm/gitk/gitk

Now do a 'git log f474c52..52b8ea9' and you'll see the merged commits.

But you are right about that 'git log -- path' will find the merge
commits only (which is right, as the tree objects are not modified when
merging, just the resulting tree has the original tree in a
subdirectory).

If this is a one-time operation then I would just use git filter-branch
to move the code to a subdir.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2009-03-27  7:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 22:59 How to merge by subtree while preserving history? David Reitter
2009-03-27  7:38 ` Miklos Vajna [this message]
2009-03-27 16:56   ` David Reitter
2009-03-27 17:20     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090327073847.GE27459@genesis.frugalware.org \
    --to=vmiklos@frugalware.org \
    --cc=david.reitter@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).