Mercurial还原和更新之间的区别 [英] Difference between Revert and Update in Mercurial

查看:72
本文介绍了Mercurial还原和更新之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用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).

据我所知,我想要的命令是恢复.

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.",它将重置 父母到第一父母.

This operation however does not change the parent revision of the working directory (or revisions in case of an uncommitted merge). To undo an uncomitted merge, you can use "hg update -C -r." which will reset the parents to the first parent.

我不了解两者之间的区别(hg reverthg 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?

推荐答案

第一个区别是还原可以在工作副本的一部分上工作,而更新可以在整个工作副本上工作.另一个区别是,当您想返回到上次提交的版本以外的版本时,会发生什么情况.

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还原和更新之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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