Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial - revert the uncommitted changes after did "hg update -C"

Tags:

mercurial

I'm new to Mercurial. I did hg status and I saw the files that changed since the last commit have M in front. I then tried hg update -C. Is there any way I can get back the version of the files with M before I did hg update -C? Or am I pretty much screwed? :( since hg update -C discards any changes since the last commit

like image 619
Jason N Avatar asked May 14 '13 22:05

Jason N


People also ask

How do you get rid of uncommitted changes in mercurial?

The revert command allows discarding unwanted uncommitted changes.

How do I revert in mercurial?

If you want to revert just the latest commit use: hg strip --keep -r . Using strip will revert the state of your files to the specified commit but you will have them as pending changes, so you can apply them together with your file to a new commit.

What does HG update do?

Use the command hg update to switch to an existing branch. Use hg commit --close-branch to mark this branch head as closed.


1 Answers

Well, let's take a look:

PS C:\dev> hg init foo
PS C:\dev> cd .\foo
PS C:\dev\foo> echo ":)" > file.txt
PS C:\dev\foo> hg add
adding file.txt
PS C:\dev\foo> hg com -m ":D"
PS C:\dev\foo> echo "DDDD" >> .\file.txt
PS C:\dev\foo> hg sta
M file.txt
PS C:\dev\foo> hg up -C
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
PS C:\dev\foo> hg sta
PS C:\dev\foo> dir


    Directory: C:\dev\foo


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         5/14/2013   4:06 PM            .hg
-a---         5/14/2013   4:06 PM         10 file.txt


PS C:\dev\foo> type .\file.txt
:)

It's gone. :( Sorry for the bad news!

like image 162
Robert P Avatar answered Sep 22 '22 03:09

Robert P