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
?
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.
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.
hg revert changes the file content only and leaves the working copy parent revision alone.
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.
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.)
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With