当没有什么可合并时如何合并 Mercurial 中的两个分支
我是 Mercurial 的新手,我正在尝试做一些非常简单的事情,但不知道如何做。我创建了一个分支来进行一些实验,而不干扰主分支。
trunk A -- B -- C
\
experiment D -- E -- F
我喜欢这个实验的进行方式,并希望将其与 trunk 合并并获取
trunk A -- B -- C -- D -- E -- F
但是,由于“trunk”分支中没有任何更改,因此合并表示没有任何内容可以合并,这很公平。我只需要结束一个名为“主干”的分支。我怎样才能做到这一点?
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
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mercurial 中的合并始终按以下方式进行:
例如,在您的情况下,您会做:
选择要更新的正确分支
在选择要更新到哪个分支以及从哪个分支进行合并时需要考虑一些事项,这与书签和分支名称有关。
先取分支名称。如果您首先更新到主干分支,然后与实验合并,则合并变更集将位于主干分支上。
但是,如果您更新到实验分支,并与主干合并,则合并变更集将位于实验分支上。
在考虑合并原因时,这一点很重要。您是否将实验合并到主干中,或者是否使用主干上发生的其他更改来更新实验。
至于书签,对于较新版本的 Mercurial,书签是不可或缺的一部分,如果您更新到书签,请像这样说:
然后提交,该书签将跟随您的提交,即。它会继续前进。
因此,如果您在主干分支的头部有一个名为 moving-target 的书签,并更新到该书签,则当您提交合并变更集时,该书签将向前移动。
Merging in Mercurial always work the following way:
For instance, in your case, you would do:
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.
As for bookmarks, with newer versions of Mercurial, bookmarks are an integral part, and if you update to a bookmark, say like this:
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.
创建分支后,您无法完全实现单个默认分支(有一些例外,请参见下文)。但是,您应该能够将
experiment
合并到default
中并实现相同的效果。如果您以此开始:
并执行此操作:
您最终应该得到以下结果:
其他选项:
使用 变基 或补丁队列< /a> 您实际上可以将
experiment
分支上的变更集重新定位回default
。这基本上会删除experiment
命名分支并创建更多default
变更集。但是,如果您已经与其他用户共享了上面第一张图片中的变更集,则无法执行此操作。Once you've created a branch, you can't exactly achieve a single default branch (with some exceptions, see below). However, you should be able to merge
experiment
intodefault
and achieve the same thing.If you start with this:
and perform this:
you should end up with this:
Other options:
Using rebase or a patch queue you could actually relocate the changesets on the
experiment
branch back on todefault
. This would basically remove theexperiment
named branch and create a few moredefault
changesets. You cannot do this, however, if you've already shared the changesets form the first image, above, with another user.