Re: Subtree merging of sub-directories between repositories?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 2, 2009 at 2:37 AM, <skillzero@xxxxxxxxx> wrote:
> Is it possible to use the subtree merge strategy to import just one
> directory from a repository into a directory of a different
> repository? The subtree merge example describes bringing in an entire
> repository as a directory, but I'm not sure how to adapt that to just
> import part of the source repository. The repositories are completely
> different, but repository A has a couple directories I want to import
> into repository B (along with the history that affected those
> directories). I may also make changes on either side and it would be
> nice to be able to re-merge in either direction.
>
> I was thinking I might need something like the git-subtree script, but
> maybe this can be done with standard git commands?

git tracks the history of the entire tree, not each subtree.  So if
you use the existing set of commit objects in A, then you'll pull in
*all* the files of A.

You have basically two choices here:

1) Merge the *entire* history of project A into project B, and during
the merge, delete the files you don't want.  (This will result in a
repo that's about the size of A+B, even if you only keep 1% of the
files, and every change to every file in A will now show up in B's
history.)  Merging future changes from A to B will be relatively easy
(although you'll get conflicts on those files you deleted), but
merging from B back to A will probably make a mess.

2) Use "git subtree split" to take the subdir of A and give it a
history of its own, then merge that history into a subdir of B (using
"git subtree add" or any other subtree merge method you want to use).
You can then git subtree split/merge back and forth between A and B in
the future to copy future changes from one to the other.

The disadvantage of #2 is that git subtree ends up creating new "fake"
commit objects for your new shared subproject.  If you merge the new
subproject back into A, you'll end up with some duplicate commit
messages (unless you use --squash).

Hope this helps.

Have fun,

Avery
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]