在 Mercurial 中,如何从变更集中提取单个文件的更改以应用于另一个分支?
我在一个分支上有许多文件的大量提交,我需要将该变更集中的单个文件的修改传输到另一个分支。我该怎么做?我主要使用 TortoiseHg,但命令行解决方案也很好。
如果我转到 TortoiseHg 中的变更集并选择文件,我可以看到我想要传输的差异,但不是实际应用它们的方法。
I have a large commit of many files on one branch, I need to transfer the modifications of a single file in that changeset to another branch. How can I do this? I am mostly using TortoiseHg but commandline solutions are also fine.
If I go to the changeset in TortoiseHg and select the file I can see the diffs I want to transfer, but not a way to actually apply them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下命令获取该文件的补丁:
然后您可以通过执行以下操作将其导入到您想要的任何分支上:
You can get the patch for just that file using:
which you can then import on whatever branch you want by doing:
最基本的解决方案是转储文件的补丁,将其应用到当前工作修订版,然后提交(假设您位于存储库的根目录):
这种方法的缺点是它不是很明显从修订历史记录的角度来看您所做的事情。良好的提交消息在这里会有所帮助,但历史图表没有给出有关移植某些更改的过程的提示。在这种情况下,合并和恢复可能是一个更好的解决方案:
可能有更多的解决方案可以做到这一点——我首先想到的是这两个。
The most basic solution is to dump the patch of the file, apply it to the current working revision, and commit it (assuming you're at the root of the repository):
The drawback of this method is that it isn't very obvious what you've done from a revision history perspective. A good commit message helps here, but the history graph gives no hint about the process of transplanting some changes. In that case merging and reverting may be a better solution:
Probably there are more solutions to do this -- these two came to my mind first.