Mercurial:将克隆转换为分支

发布于 2024-09-11 04:00:50 字数 64 浏览 4 评论 0原文

我正在尝试清理我拥有的一些克隆存储库,基本上将克隆转换为命名分支。

做到这一点最简单的方法是什么?

I am trying to clean up some cloned repositories I have, basically converting clones into named branches.

What's the easiest way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不寐倦长更 2024-09-18 04:00:50

使它们命名为分支的唯一方法是重写它们的历史记录,因为分支的名称是历史记录的一部分。 ,如果您可以在过去没有命名分支的情况下生存(未来很好),那么您可以将所有存储库拉到主存储库中(无需合并!),然后在分支进入后对其进行标记。

但是 例如,如果您有 MainRepo、Feature1Repo 和 Feature2Repo,您​​将执行以下操作:

$ cd MainRepo
$ hg pull ../Feature1Repo
$ hg pull ../Feature2Repo

现在,如果您查看 TortoiseHg 之类的 DAG,您将看到几个不同的头。从这里开始,您只需 hg uphgbranch

$ hg up feature1headrev
$ hg branch Feature1
$ hg up feature2headrev
$ hg branch Feature2

从这里开始,您将拥有命名分支。

注意:如果 hg pull 抱怨存储库不相关,您可以执行 hg pull -f,这将在存储库中创建多个尾部。这通常不是真正的分支,但有时很有用。

The only way you can make them named branches would be to rewrite their history, because the name of the branch is part of the history. However, if you can survive without having the branches be named in the past (the future is fine) then you can just pull all the repos into the main one (without merging!) and then label your branches once they're in.

For example, if you have MainRepo, Feature1Repo, and Feature2Repo, you would do the following:

$ cd MainRepo
$ hg pull ../Feature1Repo
$ hg pull ../Feature2Repo

Now, if you look at the DAG in something like TortoiseHg, you'll see a couple different heads. From here, you just hg up and hg branch:

$ hg up feature1headrev
$ hg branch Feature1
$ hg up feature2headrev
$ hg branch Feature2

From here forward, you'll have your named branches.

Note: If the hg pull complains about the repositories not being related, you can do an hg pull -f, which will create multiple tails in the repository. This is usually not how true branches are, but it is sometimes useful.

知你几分 2024-09-18 04:00:50

您可以使用 hg export 创建一组更改,然后使用 hg import 将它们添加到新分支中。

假设您有一个共同的碱基 revA,然后是两个克隆,每个克隆都从 revA 分化为 revB 和 revC。

在第一个克隆中: hg export -r revA -r revB > revB.patch
在第二个克隆中: hg export -r revA -r revC > revC.patch

现在您有两个补丁,其中包含克隆中所做的所有更改。

在原始存储库中:

hg up revA
hg branch branchB
hg commit
hg import revB.patch
hg up revA
hg branch branchC
hg commit
hg import revC.patch

现在您有两个与 revA 不同的命名分支。如果您在 revA->revB 或 revA->revC 之间的区域进行合并,我不确定这是否会完美地保留它们。

另一种选择是使用移植扩展。或者,您可以将克隆的更改推送到一个存储库中,然后将创建的头移动到新分支。

You could use hg export to create a bundle of changes, and then hg import them to your new branches.

Let's say you have a common base, revA, and then two clones which each diverge from revA into revB and revC.

In the first clone: hg export -r revA -r revB > revB.patch
In the second clone: hg export -r revA -r revC > revC.patch

Now you have two patches containing all the changes made in the clones.

In the original repository:

hg up revA
hg branch branchB
hg commit
hg import revB.patch
hg up revA
hg branch branchC
hg commit
hg import revC.patch

And now you've got two named branches diverging from revA. If you have merges in the areas between revA->revB or revA->revC, I'm not sure this will preserve them perfectly.

Another alternative is to use the transplant extension. Or you could just push your clones' changes into one repo, and then move the heads that creates to new branches.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文