丢弃 Mercurial 中的一堆提交
我用 Mercurial 做了几次承诺并推动了我的承诺。没有其他人拉他们。如何“丢弃”这些提交以将本地和远程存储库(存储库和工作目录)恢复到指定的提交? 谢谢。
I comitted few times with mercurial and pushed my commits. Nobody else pulled them. How can I "throw away" these commits to restore my local and remote repo (both repo and working dir) to a specified commit?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最快的方法是将本地存储库克隆到最后一个“好”版本,并丢弃旧版本。
仅当这些修订是历史记录中的最后 n 个修订时,这才有效。
如果您想继续推送到第三个“主”存储库,您可以将旧存储库的 .hg/hgrc 文件的
[paths]
部分复制到新存储库。The quickest way is to just clone your local repo to the last 'good' revision, and discard the old one.
This only works if those revisions are the last n in the history.
You can copy the
[paths]
section of the old repo's .hg/hgrc file to the new one if you want to continue pushing to a third 'master' repo.您可以使用
$hg revert
将代码恢复到以前的版本。如果您在命令行中输入
$hg help revert
,您将获得可恢复的方法列表。这些选项包括:
--rev
可能是您想要的选项,因为它会恢复到特定修订版。如果您想要恢复的修订版本与另一个存储库相同或与当前提示相同,那么最简单的方法可能是重新克隆该存储库。
You can use
$hg revert
to revert your code to a previous revision.If you type
$hg help revert
into your command line you'll get a list of ways you can revert.These options include:
--rev
will likely be the one you want since it reverts back to a specific revision.If the revision you want to revert to is the same as another repo or the same as the current tip, the easiest way then could be to just re-clone that repo.