在“汞还原"之后,我的更改是否消失了? [英] Are my changes gone after "hg revert"?

查看:55
本文介绍了在“汞还原"之后,我的更改是否消失了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上次提交后,我编写了很多代码.在再次提交之前,我运行了hg add. 它添加了一些我不感兴趣的文件,所以我运行了

After my last commit I wrote a bunch of code. Before committing again, I ran hg add. It added some files I was not interested in, so I ran

$ hg revert --all

认为所有添加的文件都会消失.他们确实消失了,但是我还恢复了自上一次提交以来编写的所有代码,这意味着大量工作丢失了!我有什么选择?

thinking that all the added files would go away. They did go away, but I also reverted all the code written since the last commit, which means a ton of work was lost! What are my options?

推荐答案

hg revert文件(或--all文件)时,Mercurial 以另一个名称保存文件的备份.这是为了使您更难失去工作.如果文件名为foo,您将拥有一个具有原始版本的foo.orig.

When you hg revert a file (or --all files), Mercurial saves a backup of the file under another name. This is to make it harder for you to lose work. If the file was called foo, you will have a foo.orig with the original version.

您可以使用

$ hg status --all --include "**.orig"

以查看工作副本中的所有.orig文件.将您需要的内容移回,重新添加并提交.

to see all the .orig files in your working copy. Move the ones you need back, re-add them and commit.

相关说明:人们有时会在其[defaults]部分中添加--no-backup标志,以摆脱水星散布的.orig文件.我认为这是一个非常糟糕的主意...只需忽略.orig文件,而不要添加

On a related note: people sometimes add the --no-backup flag to their [defaults] section in order to get rid of the .orig files Mercurial scatter around. I think this a really bad idea... just ignore the .orig files instead by adding

syntax: glob
*.orig

到您的.hgignore文件.这样安全得多,有一天您会高兴地发现这些.orig文件位于:-)

to your .hgignore file. That's much safer and one day you'll be happy that you have these .orig file lying around :-)

这篇关于在“汞还原"之后,我的更改是否消失了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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