how to restore file deleted with "update -C"

Lasse Vågsæther Karlsen lasse at vkarlsen.no
Mon Feb 14 11:20:31 UTC 2011


On Mon, Feb 14, 2011 at 11:07, plumo <richardbp at gmail.com> wrote:

>
> hello,
>
> I have accidentally deleted a file with mercurial and am wondering if it is
> possible to restore it.
> Here is my log:
>
...

>
> $ hg update -C
> removing main.py
> 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
>
>
> Now my main.py file is deleted. Not just removed from repository but
> deleted
> from file system! Very frustrating!
> Is there any way to restore it from mercurial's meta data?
>
>
If the file was not tracked by Mercurial at this point, no, there is no way
through Mercurial to get the file back.

This is why it's never a good idea to start issuing merge commands with
uncommitted local modifications, and wield the -C option on the update
command with care.

What you should have done when you got the message about uncommitted changes
is to issue a "hg status" command to see what those changes were, and then
decide what to do with those, before you continue.

"hg update -C" *specifically* says "discard uncommitted changes (no backup)"
in the help text.

If you don't have any way of restoring that file outside of Mercurial, like
file system backup or similar, then that file is gone.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20110214/cfacade5/attachment.html>


More information about the Mercurial mailing list