【问题标题】:How to abandon all Mercurial changes that haven't been committed如何放弃所有尚未提交的 Mercurial 更改
【发布时间】:2011-02-15 22:02:15
【问题描述】:

您如何放弃自上次在 Mercurial 中提交以来的所有存储库更改?

我不认为这是revert 命令,因为这实际上会将工作目录更新到最后一次提交。我只想撤消存储库中的更改(添加的文件、删除的文件等)。

但是,我是 Mercurial 的新手,所以我可能会遗漏一些东西。

【问题讨论】:

  • 添加的文件,删除的文件不是对存储库的更改。在提交之前,不会对存储库进行任何更改。

标签: mercurial


【解决方案1】:

任何尚未提交到存储库的本地副本更改都可以使用以下命令撤消:

hg update -C

即更新干净。

【讨论】:

  • 就是这样,真的。不容易。
【解决方案2】:

你确实想要revertrevertupdate 这两个命令是免费的。它们都更新了您工作目录中的文件,但update 也会更新父版本(参见hg parents),而revert 不会。如果您的父版本是 tip(通常是这样),那么在这种情况下两者都可以,但更喜欢 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

【讨论】:

    【解决方案3】:

    上一个问题可能会有所帮助: Mercurial — revert back to old version and continue from there

    尤其是 Martin 的“备忘单”答案。

    【讨论】:

      猜你喜欢
      • 2014-10-28
      • 2014-10-08
      • 2013-12-12
      • 1970-01-01
      • 2010-10-09
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 2011-06-25
      相关资源
      最近更新 更多