如何放弃所有尚未落实的Mercurial变更 [英] How to abandon all Mercurial changes that haven't been committed
问题描述
您如何放弃自Mercurial中的最后一次提交以来的所有存储库更改?
How do you abandon all repository changes since the last commit in Mercurial?
我不认为这是revert
命令,因为这实际上会将工作目录更新为最后一次提交.我只想撤消存储库中的更改(添加的文件,已删除的文件等).
I don't think that this is the revert
command, because that will actually update the working directory to the last commit. I just want to undo changes in the repository (added files, removed files, etc).
但是,我是Mercurial的新手,所以我可能会缺少一些东西.
But, I'm new with Mercurial, so I could be missing something.
推荐答案
您确实要revert
.两个命令revert
和update
是互补的.它们都更新工作目录中的文件,但是update
也会更新父修订版(请参见hg parents
),而revert
不会.如果您的父修订版通常是tip
,则在这种情况下两者都可以,但是更喜欢revert
.
You do want revert
. The two commands revert
and update
are complimentary. They both update the files in your working directory, but update
also updates the parent revision (see hg parents
) whereas revert
doesn't. If your parent revision was tip
, which it often is, then either would do in this case, but prefer revert
.
示例:
ry4an@hail [~/hg/test] % hg stat
? newfile
? output.patch
? this
ry4an@hail [~/hg/test] % hg add newfile
ry4an@hail [~/hg/test] % hg stat
A newfile
? output.patch
? this
ry4an@hail [~/hg/test] % hg revert --all
forgetting newfile
ry4an@hail [~/hg/test] % hg stat
? newfile
? output.patch
? this
这篇关于如何放弃所有尚未落实的Mercurial变更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!