代码之家  ›  专栏  ›  技术社区  ›  Jan

Mercurial:删除后如何恢复部分工作副本

  •  2
  • Jan  · 技术社区  · 16 年前

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

    1 回复  |  直到 16 年前
        1
  •  3
  •   Tim Post Samir J M Araujo    16 年前

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

    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
    
    推荐文章