没有合并内容时,如何合并Mercurial中的两个分支 [英] How to merge two branches in Mercurial when there is nothing to merge

查看:88
本文介绍了没有合并内容时,如何合并Mercurial中的两个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对水银技术不熟悉,我正在尝试做一些非常简单的事情,但是却不知道该怎么做.我创建了一个分支以进行一些实验,而又不会干扰主分支.

I'm new to mercurial and I'm trying to do something really simple but can't figure out how to. I created a branch to do some experimentation without disturbing the main branch.

trunk       A -- B -- C
                       \
experiment              D -- E -- F

我喜欢实验的进行方式,并希望将其与主干合并并获得

I like how the experiment went and want to merge it with trunk and get

trunk       A -- B -- C -- D -- E -- F

但是,由于"trunk"分支中没有任何更改,因此合并表明没有要合并的内容,这很公平.我只需要结束一个名为"trunk"的分支即可.我该怎么办?

However, since nothing was changed in the 'trunk' branch, the merge says that there is nothing to merge, which is fair enough. I just need to end up one branch called 'trunk'. How can I do that?

推荐答案

Mercurial中的合并始终按以下方式工作:

Merging in Mercurial always work the following way:

  1. 更新到其中一个分支(请参阅以下注释,以了解为什么要选择一个或另一个而不是随机选择一个分支的原因)
  2. 与另一个分支合并

例如,在您的情况下,您可以这样做:

For instance, in your case, you would do:

hg update trunk
hg merge experiment

选择正确的分支进行更新

选择要更新到哪个分支以及从哪个分支合并时,需要考虑一些事项,这与书签和分支名称有关.

Choosing the right branch to update to

There are some things to consider when picking which branch to update to, and which to merge from, and it has to do with bookmarks and branch names.

首先获取分支名称.如果您先更新到主干分支,然后与实验合并,则合并更改集将位于主干分支上.

Take branch names first. If you first update to the trunk branch, then merge with experiment, the merge changeset will be on the trunk branch.

但是,如果您更新到实验分支并与主干合并,则合并更改集将位于实验分支上.

However, if you update to the experiment branch, merge with trunk, then the merge changeset will be on the experiment branch.

在考虑您为什么合并时,请务必考虑这一点.您是将实验合并到中继中,还是要通过中继上发生的其他更改来更新实验.

This is important to consider when thinking about why you're merging. Are you merging the experiment into trunk, or are you updating the experiment with other changes having occured on trunk.

对于书签,在较新版本的Mercurial中,书签是必不可少的部分,如果您更新为书签,请这样说:

As for bookmarks, with newer versions of Mercurial, bookmarks are an integral part, and if you update to a bookmark, say like this:

hg update moving-target

然后提交,该书签将跟随您的提交,即.它会前进.

and then commit, that bookmark will follow your commit, ie. it will move forward.

为此,如果您在主干分支的头上有一个称为移动目标"的书签,并更新到该书签,则在提交合并合并集时,它将使该书签向前移动.

In line of this, if you have a bookmark called moving-target on the head of the trunk branch, and update to that bookmark, the merge changeset, when you commit it, will move that bookmark forward.

这篇关于没有合并内容时,如何合并Mercurial中的两个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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