Mercurial 摆脱糟糕的合并

发布于 2024-11-04 14:35:52 字数 318 浏览 2 评论 0原文

我刚刚将分支 A 合并到 B 中,由于某种原因合并进展不顺利。我想将 B 恢复到合并之前的位置,然后重试,就像以前从未发生过一样。我正在考虑

hg clone myrepo newrepo -r A -r 12345

在 B 的错误合并提交之前执行 12345 是修订号的操作,

我认为这可行,但我有很多其他分支(其中大多数是使用 commit --close-branch 关闭的),这会将这些分支放回去到非活动状态。

有没有办法克隆除修订版 123456 之外的所有内容? (其中 123456 是 B 上的错误提交)

I just merged branch A into B, and for some reason the merge did not go well. I want to revert B back to where it was before the merge and try again like it never happened before. I was thinking of just doing

hg clone myrepo newrepo -r A -r 12345

where 12345 is the revision number before B's bad merge commit

I think this works, but I have a lot of other branches (most of which are closed using commit --close-branch) and this puts those branches back to an inactive state.

Is there a way to clone everything except revision 123456 or something? (where 123456 is the bad commit on B)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

往日 2024-11-11 14:35:52

假设您尚未将合并变更集推送到任何公共位置,最简单的解决方案是使用 Mercurial Queues(即 mq)扩展附带的 hg strip 命令。

来自 wiki

hg strip rev 删除 rev 修订版
及其所有后代
存储库。删除不需要的
分支,您将指定第一个
特定于该分支的修订。经过
默认情况下,hg strip 将放置备份
.hg/strip-backup/ 目录中。如果
事实证明脱衣舞是个坏主意,你
可以用 hg unbundle 恢复
.hg/strip-backup/文件名。

Assuming you have not pushed the merge changeset to any public location, the easiest solution is to use the hg strip command that comes with the Mercurial Queues (i.e. mq) extension.

From the wiki:

hg strip rev removes the rev revision
and all its descendants from a
repository. To remove an unwanted
branch, you would specify the first
revision specific to that branch. By
default, hg strip will place a backup
in the .hg/strip-backup/ directory. If
strip turned out to be a bad idea, you
can restore with hg unbundle
.hg/strip-backup/filename.

装纯掩盖桑 2024-11-11 14:35:52

它可能不如 hg 回滚那么好,但通常我所做的就是更新到头 A,合并之前的头 B,检查这次是否正确,然后 虚拟合并 消除错误的合并。

It might not be as nice as hg rollback, but usually what I do is update to head A, merge in previous head B, check that I got it right this time, and then dummy-merge away the bad merge.

夏夜暖风 2024-11-11 14:35:52

我希望我正确理解你的情况。如果是的话,您应该能够在合并之前更新到 B 的修订版,为该修订版指定一个新的分支名称,将 A 合并到其中,然后继续。您可能希望将原始 B 分支标记为已关闭。

$ hg up 12345  #12345 is the revision of B prior to the merge
$ hg branch B-take2
$ hg merge A
$ hg commit -m 'merge A in to B-take2'

$ hg up B
$ hg commit --close-branch -m 'mark original B branch as closed'

I hope I'm understanding your situation correctly. If I am you should be able to update to the revision of B before the merge, give that revision a new branch name, merge A in to it, and continue on. You'll probably want to mark the original B branch as closed.

$ hg up 12345  #12345 is the revision of B prior to the merge
$ hg branch B-take2
$ hg merge A
$ hg commit -m 'merge A in to B-take2'

$ hg up B
$ hg commit --close-branch -m 'mark original B branch as closed'
故笙诉离歌 2024-11-11 14:35:52

现在使用 hg rollback 命令是否太晚了?如果是这样,请尝试 hg backout 命令。

Is it too late to use the hg rollback command? If so, try the hg backout command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文