我的存储库中有两个头。我在本地编辑了五个文件。 Bitbucket 存储库有 15 个我没有编辑的更改文件,但它也包含相同 5 个文件的更改版本。
我想做以下事情:
1) 如果我编辑了一个文件并且 Bitbucket 存储库包含相同的编辑文件,我希望我的更改优先。
2) 如果我没有编辑过文件,我想更新到最新版本。
Mercurial 中的哪些命令序列可以让我执行此操作?我必须使用外部程序吗?
最佳答案
本地提交
hg pull
hg update --rev ${my version}
hg merge --rev ${their version} --tool internal:local
另请参阅hg help merge-tools
没有本地提交
hg status -qn
为您提供已更改文件的列表。因为它只有五个文件,所以我会手动将它们复制走,然后还原、提取、更新并将它们复制回原位。在 unix 上你可以写一个一次性的 shell 脚本,有点像这样:
ls -l *.mine # check to see that there are none
for file in `hg status -qn`; do cp ${file} ${file}.mine; done
hg revert --all; hg pull; hg update
for file in *.mine; do cp ${file} ${file%.mine}; done
这是未经测试的代码。运行它需要您自担风险。吃松饼,开心点。
关于mercurial - 我如何在 Mercurial 中 merge 本地更改(如果有其他更改)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5865373/