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?
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?
From the documentation, you can apparently use either command to keep the file in the project history. Looks like you want remove, since it also deletes the file from the working directory.
From the Mercurial book at http://hgbook.red-bean.com/read/:
Removing a file does not affect its history. It is important to understand that removing a file has only two effects. It removes the current version of the file from the working directory. It stops Mercurial from tracking changes to the file, from the time of the next commit. Removing a file does not in any way alter the history of the file.
The man page hg(1) says this about forget:
Mark the specified files so they will no longer be tracked after the next commit. This only removes files from the current branch, not from the entire project history, and it does not delete them from the working directory.
And this about remove:
Schedule the indicated files for removal from the repository. This only removes files from the current branch, not from the entire project history.
'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.