删除所有本地变更集并还原为树 [英] Delete all local changesets and revert to tree
问题描述
我正在使用Mercurial,我在本地陷入了可怕的困境,三个头.我无法推送,我只想删除所有本地更改和提交,然后从完全干净的代码和干净的历史记录重新开始.
I'm using Mercurial and I've got into a terrible mess locally, with three heads. I can't push, and I just want to delete all my local changes and commits and start again with totally clean code and a clean history.
换句话说,我想结束于(a)与远程分支的尖端完全相同的本地代码,以及(b)没有任何本地提交的历史记录.
In other words, I want to end up with (a) exactly the same code locally as exists in the tip of the remote branch and (b) no history of any local commits.
我知道hg update -C
会覆盖所有本地更改.但是,如何删除任何本地提交?
I know hg update -C
overwrites any local changes. But how do I delete any local commits?
需要明确的是,我对保留在本地所做的任何工作都没有兴趣.我只想以最简单的方法还原到完全干净的本地结帐.
To be clear, I have no interest in preserving any of the work I've done locally. I just want the simplest way to revert back to a totally clean local checkout.
推荐答案
当最简单的方法(新的hg clone
)不可行时,我使用hg strip
:
When the simplest way (a new hg clone
) isn't practical, I use hg strip
:
% hg outgoing -l 1
% hg strip $rev # replace $rev with the revision number from outgoing
重复直到hg outgoing
保持安静为止.请注意,hg strip $rev
消除了$rev
及其所有后代.
Repeat until hg outgoing
stays quiet. Note that hg strip $rev
obliterates $rev
and all its descendants.
请注意,您可能必须首先在Mercurial设置中启用strip
.
Note that you may have to first enable strip
in your Mercurial settings.
PS:一种更聪明的方法是使用revset语言,然后执行以下操作:
PS: an even smarter approach is to use the revset language, and do:
% hg strip 'roots(outgoing())'
这篇关于删除所有本地变更集并还原为树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!