2

我在我的解决方案中删除了一个项目,提交了很多次,现在发现我仍然需要那个已删除的项目。有没有办法通过保留它的历史来恢复它?

4

1 回答 1

3

假设在存储库中实际跟踪了删除的内容:

hg revert -r (last-revision-where-files-still-existed) path/to/files/that/were/deleted

通过这样做,您只是告诉 mercurial 恢复这些文件,就像您删除它们时一样。不会还原其他文件,只需注意正确指定其先前的位置。你可以通过你的历史发现。

从输出hg --help revert

如果文件已被删除,则将其恢复。如果文件的可执行模式已更改,则将其重置。

供参考(选项)[-r 是你想要的]:

options:

 -a --all        revert all changes when no arguments given
 -d --date       tipmost revision matching date
 -r --rev        revision to revert to
    --no-backup  do not save backup copies of files
 -I --include    include names matching the given patterns
 -X --exclude    exclude names matching the given patterns
 -n --dry-run    do not perform actions, just print output

use "hg -v help revert" to show global options
于 2010-05-14T15:18:35.397 回答