41

I deleted one of the files that was in my repository locally (just at the file system level, not using hg remove). I now want to get that file back from the repository to my local directory. When I do hg status, it knows that the file is locally deleted, but there are no changes to be commited which is what I would expect.

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
ScrollerBlaster
  • 1,578
  • 2
  • 17
  • 21

3 Answers3

60
$ hg revert your-file

will restore it.

Edit: see http://www.selenic.com/mercurial/hg.1.html#revert

ctuffli
  • 3,559
  • 4
  • 31
  • 43
  • 1
    Ah yeah. And I see hg `revert --all` does it too, but thats the nuclear button. I used `--all` as I was trying to avoid typing the (in this case really long) file name. Is there a command to re-pull everything from the repository to the local directory, except for changed files. Maybe thats too long a discussion... – ScrollerBlaster Jan 20 '12 at 13:36
11

The following will revert all deleted files in the current repo:

hg status -nd0|xargs -0 hg revert
Frank
  • 119
  • 1
  • 2
6

cd to your dir and do "hg revert ." to restore all files or used any appropriate mask like *.java, etc.. This will effect only the current dir (not sure about subdirs).

Ivan Krylov
  • 356
  • 3
  • 8