How to remove changes in a file in hg

Mercurial

Mercurial Problem Overview


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?

Mercurial Solutions


Solution 1 - Mercurial

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 - Mercurial

revert --no-backup

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

hg revert --no-backup file

See also: https://stackoverflow.com/questions/7429332/how-do-you-disable-mercurial-from-leaving-orig-files-after-a-merge

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmichaelView Question on Stackoverflow
Solution 1 - MercurialAmberView Answer on Stackoverflow
Solution 2 - MercurialCiro Santilli Путлер Капут 六四事View Answer on Stackoverflow