The difference between hg forget and hg remove

mercurialversion-control

I want mercurial to remove several files from the current state of the repository. However, I want the files to exist in prior history.

How do forget and remove differ, and can they do what I want?

Best Solution

'hg forget' is just shorthand for 'hg remove -Af'. From the 'hg remove' help:

...and -Af can be used to remove files from the next revision without deleting them from the working directory.

Bottom line: 'remove' deletes the file from your working copy on disk (unless you uses -Af) and 'forget' doesn't.