mercurial - 我如何在 Mercurial 中 merge 本地更改(如果有其他更改)?

标签 mercurial merge

我的存储库中有两个头。我在本地编辑了五个文件。 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/

相关文章:

python - 有什么方法可以恢复 HG 或 GIT 变更集的下载?

ubuntu - 如何在 Ubuntu 中克隆 HG/Mercurial 远程存储库并运行 sh 文件?

mercurial - Mercurial : How to move files (to subfolder) without losing history?

r 两个数据帧按一列的绝对值合并

svn - 使用 HG Subversion 推送到 SVN 时的工作流程

version-control - hg 外部 repo 的最佳实践是什么?

git - git 中checkout 远程分支和pull 远程分支的区别?

arrays - 合并和组合数组中的哈希值

git - 如何使用 git difftool 区分 merge 冲突?

ios - xcode 在分支 merge 后用空格替换制表符