How to stop tracking a file without deleting the file

David Frey dpfrey at shaw.ca
Tue Jun 17 17:56:32 CDT 2008


On 6/17/2008, "Matt Mackall" <mpm at selenic.com> wrote:

>
>On Tue, 2008-06-17 at 12:43 -0400, Martin Chabot wrote:
>> I have added accidentally some files in the repository that I don't want
>> to be tracked. I modified my .hgignore, committed it. This does not do
>> the trick. I think I need to do a hg remove.  The problem is that it
>> removes the file in my working directory and I don't want that. I
>> imagine there is a way of doing this.
>
>Have you tried 'hg help remove' yet? You want 'hg rm -Af'.

It looks like this does solve the problem, but as a solution, it is
completely unintuitive.  Personally, one of the reasons I like Mercurial
is because it is intuitive and discoverable for the most part.

Examining the remove command:

-A == --after
-f == --force

"after" is a way to tell Mercurial to stop tracking the files that I
have already removed from disk.

"force" is a way of saying remove the file even if the file has been
added, but not committed or is modified.

Somehow combining the two options means stop tracking this file, but do
not delete it from disk.  I would prefer to see this functionality in
its own option.  Something like --keep-file might be appropriate.

The --keep-file and --after options could not be specified together as
they conflict with each other.

I would be willing to implement this myself if people agree that it's
the right thing to do.

Cheers,
David Frey



More information about the Mercurial mailing list