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

I am new to Mercurial. I did hg status and I saw files that have changed since the last commit with M in front. Then I tried hg update -C . Is there a way to return the version of files using M before I did hg update -C ? Or did I mess up pretty much? :( since hg update -C discards any changes since the last commit

+6
source share
3 answers

Unfortunately, it is located directly in hg help update :

 options: -C --clean discard uncommitted changes (no backup) 

The right workflow would be to commit your outstanding changes (which would supposedly create a new head) and merge your commit with the changes you wanted to import.

If you don’t like making a semi-arid set of changes, check out the shelve extension, which is designed for just that: it temporarily defers all or some of your uncommitted changes, allowing you to run hg operations before returning them again. ( shelve not distributed via mercury, but I think tortoisehg may include it).

+11
source

A pretty late answer for Jason, but may help others.

We had the same problem and FOUND THE SOLUTION here ...

In short:

  • type hg heads - you will see that the head of your changes is somewhere in the repository
  • Copy id of your head and type hg update <id_of_your_head>
0
source

Ok, let's see:

 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 :) 

Everything went. :( Sorry for the bad news!

-1
source

Source: https://habr.com/ru/post/945023/


All Articles