Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial discard local changes of a file or group of files or all

Tags:

mercurial

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
like image 776
Umair A. Avatar asked Sep 17 '13 09:09

Umair A.


People also ask

How do you dispose of local changes in Mercurial?

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.

How do I delete a file from Mercurial?

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

How do I revert a commit in Mercurial?

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.

What is hg status?

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.


1 Answers

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.

like image 116
shamp00 Avatar answered Nov 18 '22 15:11

shamp00