80

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?

alex
  • 479,566
  • 201
  • 878
  • 984
michael
  • 106,540
  • 116
  • 246
  • 346

2 Answers2

104
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.)

Amber
  • 507,862
  • 82
  • 626
  • 550
  • 8
    Actually, git reset should only be used when you want to discard _all_ local changes. Michael's git command is correct. – kipple Apr 08 '13 at 19:08
  • This does not work during the merge though: `abort: uncommitted merge with no revision specified` – Ivan Balashov Mar 10 '17 at 17:53
8

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?

Community
  • 1
  • 1
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985