如何摆脱汞的一些变化? [英] How to get rid of some changeset in Hg?

查看:99
本文介绍了如何摆脱汞的一些变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我偶然发生了一些变化,所以我希望能够改变这些变化。撤消那个。试了一下后,我能够 hg backout ,但它创建了一个新的提交。现在,我想让我的回购变成初始状态(没有最后2次提交以及我在工作目录中的更改)。显然没有办法做到这一点(类似于 git reset --soft )。有没有?



我试过的另一件事是摆脱最新的提交(恢复原来的提交)。它会类似于 git reset --hard ,但是再次,没有办法做到这一点。我可以 hg update -C ,但这更像是 git checkout ,因为提交仍然存在。 / p>

另外, hg update -C -r X 会将我恢复到版本X,但是当我检查 hg log 没有办法让我知道我现在在哪个版本中。唯一的方法是检查我的bash历史,这是正确的吗?有一种方法可以知道这一点。



无论如何,我一直试图对此进行排序,但找不到任何解决方法。我发现比较git和hg命令的引用不准确,因为命令没有完全相同的行为。



我想我只是想知道什么是对于 git reset --hard git reset --soft 的REAL等价。

谢谢。

解决方案

Mercurial故意不做这很简单。 Mercurial的想法是,承诺的代码应该继续存在 - 没有发挥作用的记录几乎与记录所做的一样重要。最好承诺否定你的工作(这就是 backout 的做法)并且仍然有记录,而不是实际放弃它。



然而,如果你不能离开这个改变(很好的理由:它包含一个你不能改变的密码,不好的理由:它只是没有解决),你有几个选择:




  • strip:我不喜欢strip它会修改存储库并且不会将这些东西放回到工作目录中。 Strip是默认禁用的。

  • clone:只要做一个 hg clone -r LASTCHANGESETYOULIKE oldrepo newrepo 现在newrepo拥有所有东西直至并包括LASTCHANGESETYOULIKE。归档oldrepo并将newrepo重命名为oldrepo。

  • rollback:这是mercurial世界的单层撤消。它会在你做完之后立即撤消你的提交权限,但是如果你做了其他任何提交或提交,那么它就不起作用。


Hey, I want to revert some changesets in Hg but I'm having a hard time doing so.

I commited some changes by accident, so I wanted to undo that. After trying a little bit, I was able to hg backout, but it created a new commit. Now, I wanted my repo to became to the initial state (without the last 2 commits and with my changes in the working dir). Apparently there's no way of doing that (something similar to git reset --soft). Is there?

Another thing I tried was to get rid of the latest commit (the one that reverted the original one). It would be something similar to git reset --hard, but again, there's no way to do that. I can hg update -C, but that is more like git checkout, since the commit is still out there.

And also, hg update -C -r X reverts me back to revision X, but when I check hg log there's no way for me to know in which revision I am right now. The only way is to check my bash history, is this right? There's gotta be a way to know this.

Anyway, I've been trying to sort this out for a while but couldn't find anything that would solve it. The references I found comparing git and hg commands are not accurate, since the commands don't have the exact same behavior.

I guess I just want to know what are the REAL equivalences in hg for git reset --hard and git reset --soft...

Thanks.

解决方案

Mercurial intentionally doesn't make this easy. Mercurial's mindset is that code committed should continue to exist -- that the record of what didn't work out is almost as important as a record of what did. It's better to commit the negation of your work (which is what backout does) and still have the record than it is to actually discard it.

If, however, you just can't leave that change around (good reasons: it contains a password you can't change, bad reason: It just didn't work out) you have a few options:

  • strip: I don't like strip it modifies the repository and doesn't put the stuff back in the working dir. Strip is disabled by default for a reason.
  • clone: Just do a hg clone -r LASTCHANGESETYOULIKE oldrepo newrepo and now newrepo has everything up to and including LASTCHANGESETYOULIKE. Archive oldrepo and rename newrepo to oldrepo.
  • rollback: This is the one-level undo of the mercurial world. It would have undone your commit right after you did it, but it doesn't work if you've done any other pulls or commits, which you have.

这篇关于如何摆脱汞的一些变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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