Mercurial 撤消三汞推送
我正在使用 Mercurial VCS,我错误地推送了三个提交,我希望它们被撤消,这可以实现吗? 我很确定没有任何更改从我推送到的存储库传播给任何人,所以我相信这不会破坏任何人的代码...
我已经尝试过 hg 回滚,但自从我推送以来,我无法撤消任何内容正确的方法。我也知道 hg backout,但我不确定我是否应该使用这个来满足我的需要......
谢谢!
编辑
这是图形日志,我忘记提及一些提交是合并的一部分,但它们也需要撤消...
tip
|
a
| \
| b
| /
c
|
d
我需要将提示返回到 c 或 d 如果没有其他方法可以防止这种情况因为合并...
I'm using mercurial VCS, I've mistakenly pushed three commits and I want them to be undone, can this be achieved?
I'm pretty sure no changes were propagated to anyone from the repository I pushed to, so I'm confident that this won't break anyones code...
I've tried hg rollback but since I have pushed I cannot undo anything in the right way. Also I know about hg backout, but I'm not sure if I should use this one for what I need...
Thanks!
EDIT
This is the graph log, I forgot to mention that some commits were part of a merge, but they too need to be undone...
tip
|
a
| \
| b
| /
c
|
d
I need to return the tip to c, or d if there is no other way to prevent that because of the merge...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它已经推送,那么您现在只能做两件事:
1) 如果您能够删除中央存储库并将其替换为另一个存储库:
您可以克隆中央存储库,但告诉 Mercurial 仅克隆最多变更集“c”。
然后,您可以使用此存储库(没有错误的更改)并用它替换“旧”中央存储库(确实有错误的更改)。
缺点:如果有人已经拉取了不需要的提交并稍后再次推送,它们会再次位于存储库中。
因此,您需要确保要么没有人犯下错误,要么犯下错误的每个人都删除了他的克隆。
2) 如果选项 1 不可行,您可以使用
hg backout
< /a> 撤消错误更改的影响 - 而不是更改集本身。引用链接中的内容:
因此,三个错误的变更集将保留在存储库中,另外将添加另外三个变更集,每个变更集都会恢复三个错误变更集之一的影响。
如果你这样做,即使其他人已经拉了错误的更改也没关系……一旦他也拉了三个“撤销”变更集,一切都会恢复正常。
If it's already pushed, there are only two things that you can do now:
1) If you are able to delete the central repository and replace it by another one:
You can clone the central repository, but tell Mercurial to clone only up to changeset "c".
Then you can take this repository (which doesn't have the wrong changes) and replace the "old" central repository (the one which does have the wrong changes) with it.
Disadvantage: if someone already pulled the unwanted commits and later pushes again, they are in the repository again.
So you need to make sure that either no one pulled the mistakes, or everybody who did deletes his clone.
2) If option 1 is not possible, you can use
hg backout
to undo the effects of the wrong changes - not the changesets themselves.Quote from the link:
So the three wrong changesets will remain in the repository, plus another three will be added, each of them reverting the effects of one of the three wrong changesets.
If you do it like this, it doesn't matter if someone else already pulled the wrong changes...as soon as he pulls the three "backout" changesets as well, everything is okay again.
如果您确信推送是该远程存储库发生的最后一件事,这意味着您或其他任何人都没有推送到它,您可以登录到该系统并运行
hg rollback
。如果它是您可以 ssh 访问的计算机上的存储库,您可以在本地系统上运行此命令:
一如既往,请务必小心回滚。它会撤消存储库上的最后一个操作,而根本不会更改工作目录,并且并不总是清楚最后一个操作是什么。例如,这是数据丢失:
哎呀!
If you're positive the push is the last thing that happened to that remote repository, meaning neither you nor anyone else has pushed to it, you can login to that system and run
hg rollback
.If it's a repository on a machine to which you can ssh you can run this command on your local system:
As always please do be really careful with rollback. It undoes the last action on the repository without altering the working directory at all, and it's not always clear what the last action was. For example, this is datalosss:
Yikes!