如何还原上一次提交并保持更改? [英] How to revert last commits and keep changes in mercurial?

查看:68
本文介绍了如何还原上一次提交并保持更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个提交1、2和3.如何回滚2和3并仍然保留它们的更改文件?

I have three commits 1, 2 and 3. How can I rollback 2 and 3 and still keep the changed files of them??

1---2---3

=> 1 and changed files of 2 and 3

推荐答案

您使用strip命令:

存储库中的变更集及其所有后代

strip changesets and all their descendants from the repository

带有--keep选项:

-k --keep在删除期间不修改工作副本

-k --keep do not modify working copy during strip

并且由于strip对历史具有破坏性,因此默认情况下未启用它.您可以通过将以下几行添加到~/.hgrc文件中来启用它:

And since strip is destructive of history it's not enabled by default. You enable it by adding these lines to your ~/.hgrc file:

[extensions]
strip =

因此,在这种情况下,您将执行hg strip --keep 2

So in this case you'd do hg strip --keep 2

注意:需要Mercurial 2.8或更高版本.在此之前,您需要将mq =放在.hgrc中.

Note: requires Mercurial 2.8 or later. Before that you need to put mq = in the .hgrc instead.

这篇关于如何还原上一次提交并保持更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆