问题描述
我刚刚开始使用 Mercurial,遇到了一些我不明白的事情.
I'm just getting started with Mercurial, and I've come across something which I don't understand.
我对多个文件进行了更改,现在我想撤消对其中一个文件所做的所有更改(即返回到我对一个特定文件的最后一次提交).
I made changes to several files, and now I want to undo all the changes I made to one of them (i.e. go back to my last commit for one specific file).
据我所知,我想要的命令是 revert.
As far as I can see, the command I want is revert.
在我链接的页面中,有如下声明:
In the page I linked to, there is the following statement:
但是这个操作并没有改变工作的父修订目录(或修订,以防万一未提交的合并).撤消未提交的合并,您可以使用hg更新 -C -r." 这将重置第一个父母的父母.
我不明白两者之间的区别(hg revert
与 hg update -C -r
).任何人都可以启发我的区别吗?就我而言,我是否真的希望还原或更新删除我对文件所做的更改?
I don't understand the difference between the two (hg revert
vs. hg update -C -r
). Can anyone enlighten me as to the difference? And in my case, do I really want the revert or the update to go get rid of the changes I made to the file?
推荐答案
第一个区别是 revert 可以作用于工作副本的一个子集,而 update 可以作用于整个工作副本.另一个区别在于,当您想返回到上次提交的版本以外的版本时会发生什么.
The first difference is revert can work on a subset of the working copy while update works on the whole working copy. the other difference is in what happens when you want to go back to a version other than the last committed one.
如果我们有修订(大写已提交,小写是工作副本中的更改,父修订为 C)
if we have revisions (caps are committed, lower case are changes in the working copy, parent revision is C )
A-B-C-d
update -C -r B
会给你
A-B-C
当您的工作副本设置为 B 时,任何更改都将导致从 B 分支(父修订设置为 B)
with your working copy set to B, any changes will result in branching from B (parent revision set to B)
A-B-C
e
revert -r B
会给你
A-B-C-b'
其中 b' 是一组更改,它撤消中间提交的更改中的所有内容,在这种情况下,它撤消所有 C.现在任何更改都加入 b' 集(父修订版在 C 处保持不变)
where b' is a set of changes which undoes everything in the intermediate committed changes, in this case it undoes all of C. any changes now just join the b' set (parent revision left unchanged at C)
这篇关于Mercurial中Revert和Update的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!