如何从 Mercurial 中的跟踪中删除文件夹

how to remove a folder from tracking in mercurial

./node_modules/ 文件夹和 .idea 文件夹忽略到 .hgignore 文件中,这样我就不会想追踪他们。

目前我的 .hgignore 文件中有以下规则。

*.orig
*./node_module/
*.idea/ 
*.rej
*~
*.o
tests/*.err

但在 hg status 上出现中止错误。

嗯,hg help hgignore点来看看hg help patterns。我无法更好地解释它:

Mercurial accepts several notations for identifying one or more files at a
time.

By default, Mercurial treats filenames as shell-style extended glob
patterns.

Alternate pattern notations must be specified explicitly.

Note:
  Patterns specified in ".hgignore" are not rooted. Please see 'hg help
  hgignore' for details.

To use a plain path name without any pattern matching, start it with
"path:". These path names must completely match starting at the current
repository root.

To use an extended glob, start a name with "glob:". Globs are rooted at
the current directory; a glob such as "*.c" will only match files in the
current directory ending with ".c".

The supported glob syntax extensions are "**" to match any string across
path separators and "{a,b}" to mean "a or b".

(...)

Plain examples:

  path:foo/bar   a name bar in a directory named foo in the root
                 of the repository
  path:path:name a file or directory named "path:name"

有其他方法可以使用正则表达式指定路径,并且在可用的命令行帮助中也有说明。

所以,使用像

这样的东西
node_module/**
.idea/**

path:node_module
path:.idea

前提是您引用了整个 .hgignore 并因此使用默认的 glob 模式匹配。

我终于找到小费了。这是如何。 要添加 node_modules/.idea/ 文件夹,您需要指定以下内容。N.B >是指终端。

touch .hgignore nano .hgignore

添加以下内容

^node_modules/
^.idea/

完成!