在 hg update 删除它们后,我可以取回我的代码更改吗?

Can I get back my code changes after hg update removed them?

我是 Mercurial 新手。我对一些文件中的代码做了一些更改,但我还没有提交它们。但是当我做 hg update -c <branch-name> 时,我所有的代码更改都消失了。有什么方法可以恢复我的代码更改,还是我搞砸了?

很遗憾,没有,如更新帮助 (hg help update) 中所述,--clean 不创建备份。

检查您是否可以使用带有 CTRL + Z 的文本编辑器获取旧版本的文件,它已经救了我的命。

您是否正在使用非常非常旧版本的 Mercurial?

hg update 的帮助显示 -c 不会丢弃未提交的更改:

 -C --clean     discard uncommitted changes (no backup)
 -c --check     update across branches if no uncommitted changes

这种情况至少持续了四年。如果您尝试更新到一个会丢弃您的本地更改的修订版,Mercurial 会警告您:

ry4an@four:~/test$ hg checkout 0
abort: uncommitted changes
(commit or update --clean to discard changes)

如果您使用 -c 它应该什么都不做。如果您使用 -C,您应该找到建议您这样做的人并向他们大喊大叫。

对于您的损失,我们深表歉意。 :(