Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove changes in a file in hg

Tags:

mercurial

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?

like image 381
michael Avatar asked May 04 '10 02:05

michael


People also ask

How do I undo hg revert?

Caveat: Doing hg remove [file] on an unmodified file removes the file from the filesystem. In this case, hg add [file] fails and to add it back you have to do hg revert [file] . hg add [file] is the correct answer for files that have been modified prior to removal.

How do you dispose of local changes in Mercurial?

The -C flag tells the update command to discard all local changes before updating. In any case, there is no single one command you can ask Mercurial to perform that will do everything you want here, except if you change the process to that "full clone" method that you say you can't do.

What is hg revert?

hg revert changes the file content only and leaves the working copy parent revision alone.

How do I revert a commit in Heartgold?

If you want to revert just the latest commit use: hg strip --keep -r . Using strip will revert the state of your files to the specified commit but you will have them as pending changes, so you can apply them together with your file to a new commit.


2 Answers

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

like image 106
Amber Avatar answered Oct 13 '22 06:10

Amber


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?