开发者

How to abandon all Mercurial changes that haven't been committed

How do you abandon all repository changes since the last commit in Mercurial?

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).

But, I'm new with M开发者_StackOverflow中文版ercurial, so I could be missing something.


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.

Example:

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


Any changes to your local copy that have not been committed to the repository can be undone with the command:

hg update -C

That is, update clean.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜