How to remove changes in a file in hg

36,058

Solution 1

hg revert <filename>

More detail on available hg commands is available on the man page.

(Note that this is not the same as git revert - git's revert command is for reverting commits, hg's revert command is for reverting local changes. Also, the command you should really be using to remove local changes in git is actually git reset, not checkout.)

Solution 2

revert --no-backup

Prevents the creation of .orig files, more closely emulating git checkout:

hg revert --no-backup file

See also: How do you disable mercurial from leaving .orig files after a merge?

Share:
36,058

Related videos on Youtube

michael
Author by

michael

Updated on July 05, 2022

Comments

  • michael
    michael almost 2 years

    Can you please tell me how can I remove change I made locally?

    In git , I can do git checkout -- aFile.cpp, how can I do the same thing with hg?

  • kipple
    kipple about 11 years
    Actually, git reset should only be used when you want to discard all local changes. Michael's git command is correct.
  • Ivan Balashov
    Ivan Balashov over 7 years
    This does not work during the merge though: abort: uncommitted merge with no revision specified