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
Unfortunately, it's right there in hg help update
:
options:
-C --clean discard uncommitted changes (no backup)
The proper workflow would have been to commit
your outstanding changes (which would presumably create a new head) and merge
your commit with the revisions you wanted to import.
If you don't like having to commit a half-baked set of changes, check out the shelve
extension, which is designed exactly for this: It temporarily puts aside all or some of your uncommitted changes, allowing you to run hg
operations before you bring them back again. (shelve
is not distributed with mercurial, but I think tortoisehg
may include it).
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!
Some IDE's, like Intellij will separate from version control keep track of "Local History" I would check for that in a case like this.
Quite late answer for Jason, but may help the others.
We had the same problem and FOUND A SOLUTION here...
In brief:
- type
hg heads
- you will see head of your changes is stil somewhere in the repository - copy ID of your head and type
hg update <id_of_your_head>
© 2022 - 2024 — McMap. All rights reserved.