How can I recover a removed file in Mercurial (if at all)?

后端 未结 9 749
有刺的猬
有刺的猬 2020-12-23 08:38

Accidentally, by using a GUI as opposed to CLI, I removed every file in a Mercurial project.

I recovered with Revert ok and lost some work, which as I have time mach

9条回答
  •  时光说笑
    2020-12-23 09:40

    For Mercurial 1.6 and above

    If you know the name of the delete file you can find its revision easily with:

    hg log -r "removes('NAME.c')"
    

    This will give you the revision in witch a file called NAME.c (in the root) is deleted.

    Then you can revert the file to the previous revision with (like other answers):

    hg revert -r  
    

    You can use a file name pattern instead to adapt to what you know, for example you can use **/NAME.c to search in all directories. You can read about it in File Name Patters. And use this link to know about the new revset specifications.

提交回复
热议问题