Mercurial: how to get back part of a working copy after deleting

I deleted the project in my solution, committed many times and now figured out that I still need this deleted project. Is there a way to restore it while keeping history?

+2


a source to share


1 answer


Assuming what was removed is actually tracked in the repository:

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

      

By doing this, you are simply saying that Mercurial returns these files as they were when you deleted them. No other files will be overridden, just take care to correctly point to their previous locations. You may find that you are just browsing your history.

From the output hg --help revert

:



If the file was deleted, it is restored. If the executable mode of the file has been changed, it is reset.

And for reference (options) [-r is what you want here]:

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

      

+3


a source







All Articles