我有两个脑袋,让我们称它们为"A"(好头)和"B"(坏头).我希望通过从A中取出所有内容并且从B中取而代之的来合并它们.基本上,我和A的合并是A.
当我尝试hg merge时,它开始向我询问这个文件,并且不可避免地我遇到了麻烦.我不想要任何这个!我怎么能告诉它合并它们并最终得到A,最好没有任何中间步骤?
pyf*_*unc 27
来自第22节的Mercurial提示.合并时保留"我的"或"他们的"文件.
有时你想要合并两个头,但是你想要丢弃其中一个头的所有变化,即所谓的虚拟合并.您可以使用ui.merge配置条目覆盖合并:
$ hg --config ui.merge=internal:local merge #keep my files
$ hg --config ui.merge=internal:other merge #keep their files
Run Code Online (Sandbox Code Playgroud)
这里local表示工作目录的parent,另一个是你要合并的head.这将遗漏另一个负责人的更新.
要将X合并到当前版本中而不让X中的任何更改通过,请执行以下操作:
hg --config ui.merge=internal:fail merge X
hg revert --all --rev .
Run Code Online (Sandbox Code Playgroud)
另一种方法在:https://www.mercurial-scm.org/wiki/PruningDeadBranches中提到
$ hg update -C tip # jump to one head
$ hg merge otherhead # merge in the other head
$ hg revert -a -r tip # undo all the changes from the merge
$ hg commit -m "eliminate other head" # create new tip identical to the old
Run Code Online (Sandbox Code Playgroud)
Mat*_*att 18
我最近在一些个人回购中遇到的一件事就是使用带分支的close-branch开关.例如
$ hg update B
$ hg commit --close-branch -m "Abandoning branch"
Run Code Online (Sandbox Code Playgroud)
在我的推理中,如果你正在吹掉一个分支而完全支持另一个分支,那么它根本就不是合并而且称它为愚蠢.我对自己来说相对较新,而且我似乎记得 - 关闭分支从一开始就没有出现过,也许这就是为什么它没有像我通常看到的合并回转那么大的牵引力.