Search code examples
version-controlmercurial

Mercurial - how to retrieve orig file after a revert?


I accidentally ran hg revert and lost all changes to my file foo.js. I see that a backup of the file exists as foo.js.orig. How can I add the orig file back so that I can reinstate my changes?

Update: I used hg add foo.js.orig to add the file back, but how can I replace the existing foo.js file with the original foo.js.orig file? I am new to mercurial so any help appreciated, thanks!


Solution

  • I solved this by:

    1. Adding the file back using hg add foo.js.orig
    2. Renaming the file using hg rename -f foo.js.orig foo.js (this replaces the existing-but-outdated foo.js file)