如何删除 Mercurial 中应用于错误分支的一些提交,然后在正确的分支上重播它们?
我的同事在错误的分支上的存储库上提交了两次。
采取这两个提交、删除它们然后将它们正确提交到正确的分支下的最有效方法是什么? (更改尚未推送)
我们理想地希望有一种方法可以从 TortoiseHG 内部执行此操作,但当然,如果命令行是最佳选择,我们将使用它。
My colleague has committed twice on his repository on the wrong branch.
What is the most effective way to take those two commits, get rid of them and then commit them correctly under the right branch? (the changes have not been pushed)
We'd ideally like a way to do this from within TortoiseHG but of course, we'll use the command-line if it is the best option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Mercurial 队列 (mq) 扩展可以提供帮助。
给定如下所示的更改历史记录:
以下命令将文件“file4”变更集移动到另一个分支(“file2”头):
结果:
请注意,修订版 3 的变更集哈希已更改,因为变更集具有不同的值现在为人父母。 TortoiseHg 的更高版本也支持 MQ 扩展。
The Mercurial Queues (mq) extension can help.
Given a change history that looks like this:
The following commands moves file 'file4' changeset onto the other branch (the 'file2' head):
Resulting in:
Note that the changeset hash for rev 3 changed, due to the changeset having a different parent now. Later versions of TortoiseHg support the MQ extension as well.
据我所知,移植是最好的扩展。它将变更集应用于您想要的任何其他修订。
http://mercurial.aragost.com/kick-start/tasks.html #transplanting-changes
我的问题的解决方案是更新到应该应用两个更改的分支,移植两个更改集,然后使用 mq 删除更改。所有这些都可以在 tortoisehg 中完成。
From what I have found out, transplant is the best extension to use. It applies a changset to any other revision you want it to.
http://mercurial.aragost.com/kick-start/tasks.html#transplanting-changes
The solution to my problem was to update to the branch where the two changes should have been applied, transplant the two changesets in and then use mq to strip the changes. All do-able within tortoisehg too.
在这种情况下,最好使用 hg rebase。
https://www.mercurial-scm.org/wiki/RebaseExtension
In this case it is much better to use
hg rebase
.https://www.mercurial-scm.org/wiki/RebaseExtension