From Mercurial FAQ page I read how to discard all local changes of my repo.
hg update -C -r
But what I want is to discard local changes in particular file and/or a group of files separated by space/comma. I tried following command but why this is not working?
hg update relative/path/to/my/file.rb
Reverting Local Changes If you use the TortoiseHg client to work with Mercurial from TestComplete, you can cancel all local changes not committed to the repository yet: Select File > Source Control > Revert from the TestComplete main menu.
Once you decide that a file no longer belongs in your repository, use the hg remove command. This deletes the file, and tells Mercurial to stop tracking it (which will occur at the next commit). A removed file is represented in the output of hg status with a “ R ”.
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 status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.
You can use revert
hg revert --no-backup file.rb
As of Mercurial 2.0, you can use
hg revert -C file.rb
to prevent the creation of .orig files.
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