合并两个不同的存储库 [英] Merging two different repositories

查看:90
本文介绍了合并两个不同的存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个存储库A,B和C,它们都与同一个项目有关. A是该项目的最旧版本,B是一个没有真正进行到任何地方的实验,C是最新的工作版本.所有这些存储库都有不同的文件-它们是同一产品的不同实现.

I've 3 repos, A, B and C, all related to the same project. A is the oldest version of the project, B is an experiment that didn't really go anywhere and C is the latest working version. All these repos have different files - they're different implementations of the same product.

我想将这三个存储库合并为一个,以保留其历史记录-这至关重要.我想我想将B堆叠在A的顶部,将C堆叠在B的顶部,但是当我签出项目时,我只想获取与仓库C相关的更改.

I'd like to merge these 3 repos into one keeping their history - this is vital. I guess I want to stack B on top of A and C on top of B but when I checkout the project I only want to get the changes related to repo C.

我的想法是在A上标记或创建一个命名分支,hg rm *,提交,然后将B堆在顶部.对B重复相同的操作,这样我就可以将C堆积起来,然后照常继续进行该项目.

My idea is to tag or create a named branch on A, hg rm *, commit and then pile B on top. Repeat the same with B so I can pile C and then continue on the project as usual.

您怎么看?另外,我想做的事情也有一些启示: 1 2 .

What do you think? Also, some inspiration for what I want to do: 1, 2.

推荐答案

您可以将变更集放入一个大型存储库中.从A回购开始:

You can just pull the changesets into one big repository. Start with the A repo:

$ hg init combined
$ cd combined
$ hg pull ../A
$ hg update

然后强行拉入B并虚拟合并两个头,以使文件不被B遮挡:

Then forcibly pull in B and dummy-merge the two heads so that you keep the files from B:

$ hg pull ../B --force
$ hg merge --tool internal:other
$ hg revert --all --rev tip
$ hg commit -m "Merge A and B, kept B"

然后重复C:

$ hg pull ../C --force
$ hg merge --tool internal:other
$ hg revert --all --rev tip
$ hg commit -m "Merge B and C, kept C"

这提供了三行历史记录和一个合并点,在该合并点处,您首先丢弃A,然后丢弃B,最后得到C.

That gives you three lines of history and a merge point where you first throw away A, then B, and finally end up with C.

或者,您可以将转换扩展名拼接图将这三个历史结合在一起.首先,将所有变更集强制拉到一个存储库中.然后进行Mercurial到Mercurial的转换,在其中将A的尖端添加为B的根的第一个父级.对于B和C同样如此.这给了您悠久的历史,当您从A转到B时,会发生非常突然的变化. B,然后从B到C.

Alternatively you can use the convert extension with a splice map to splice the three histories together. Start by forcibly pulling all the changesets into a single repository. Then do a Mercurial to Mercurial conversion where you add the tip of A as the first parent of the root of B. Similarly for B and C. That gives you one long history where there will be a very abrupt change when you go from A to B and from B to C.

我会选择第一个选项:这是最明确的选项,它可以很好地显示发生的事情而不会伪造(转换)历史记录.

I would go with the first option: it's the most explicit and shows best what happens without faking (converting) the history.

这篇关于合并两个不同的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆