Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Mercurial中合并时忽略不存在的文件_Mercurial_Merge - Fatal编程技术网

在Mercurial中合并时忽略不存在的文件

在Mercurial中合并时忽略不存在的文件,mercurial,merge,Mercurial,Merge,我正在使用一个具有稳定和实验分支的存储库。有时,我会在实验分支上添加一个尚未准备好用于稳定分支的文件。合并时,我希望合并两个分支共有的文件中的更改,但忽略其中一个分支上不存在的文件 下面是一个简单的例子: hg init hg branch stable (create file A) hg add A hg commit -m "Added A" hg branch exp (create file B) hg add B hg commit -m "Added B, which is re

我正在使用一个具有稳定和实验分支的存储库。有时,我会在实验分支上添加一个尚未准备好用于稳定分支的文件。合并时,我希望合并两个分支共有的文件中的更改,但忽略其中一个分支上不存在的文件

下面是一个简单的例子:

hg init
hg branch stable
(create file A)
hg add A
hg commit -m "Added A"

hg branch exp
(create file B)
hg add B
hg commit -m "Added B, which is really experimental"

(modify file A)
hg commit -m "Some changes to A"

hg update stable
hg merge exp
无论我如何更改合并工具配置,Mercurial似乎总是将B与合并一起使用。因为它不存在于稳定分支上,所以它从来都不是冲突

我可以做到以下几点:

hg update stable
hg merge exp
hg commit -m "Merged"
hg revert -r 0 B
但这需要我知道哪些文件需要恢复


有没有想过最简单的方法让合并忽略一个分支上不存在的文件,最好是自动进行合并?

你不能要求Mercurial做你想做的事情

您不合并单个文件,而是合并整个分支,这意味着作为分支一部分的所有文件都将成为合并的一部分。这就是Mercurial的设计和运作方式

现在,您可以在提交之前还原/忘记/删除不需要的文件,但之后您只是在为自己设置灾难


我建议您将要保留的内容与不知道是否要保留的内容分开,这样您就可以合并一个分支,让另一个分支暂时分离。

Mercurial正按照您的要求进行操作。您告诉它在
exp
分支上获取您的更改,并将它们合并到
stable
分支中。这包括新文件。您是否试图将
stable
中的更改合并到
exp
?也许您应该考虑一下您的分支概念,并使用第三个分支进行真正的实验性更改。