如何停止跟踪文件而不在Mercurial上删除它

Ame*_*ina 26 mercurial

我看到了这个讨论解决方案的线程git,并在Mercurial的邮件列表中找到了这个帖子(该线程已经四年了)

邮件列表中提出的解决方案是使用hg rm -Af file(并且他们将实现此行为的可能性作为一种新的,更直观的选项).我想知道现在是否存在该选项.

另外,如果我尝试上面的命令:

> hg rm -Af my_file
> hg st
R my_file
Run Code Online (Sandbox Code Playgroud)

有一个R旁边my_file,但文件my_file在技​​术上是在磁盘上,我告诉Mercurial停止跟踪它,为什么我要R接下来呢?

Cés*_*sar 24

您可以使用hg forget或可能将文件添加到您的.hgignore文件中

并回答关于Rin 的最后一个问题my_file.如果您看到以下帮助hg rm --help:

hg删除[选项] ...文件...

别名:rm

在下次提交时删除指定的文件

Schedule the indicated files for removal from the current branch.

This command schedules the files to be removed at the next commit. To undo
a remove before that, see "hg revert". To undo added files, see "hg
forget".

Returns 0 on success, 1 if any warnings encountered.
Run Code Online (Sandbox Code Playgroud)

选项:

-A - 记录删除丢失的文件
-f --force删除(和删除)文件,即使添加或修改
-I --include PATTERN [+]包含与给定模式匹配的名称
-X --exclude PATTERN [+]排除与给定模式匹配的名称

[+]标记选项可以多次指定

使用"hg -v help remove"来显示更多信息

正如您所看到的那样,您正在强制删除该文件,这就是您可以看到R(已删除)的原因