如何忽略 Mercurial 文件夹下的所有内容

发布于 2024-07-08 17:15:03 字数 110 浏览 5 评论 0原文

我正在寻找 .hgignore 文件的表达式,以忽略指定文件夹下的所有文件。

例如:我想忽略 bin 下面的所有文件和文件夹

实际上,关于如何形成表达式的任何建议都会很棒

I am looking for an expression for the .hgignore file, to ignore all files beneath a specified folder.

eg: I would like to ignore all files and folders beneath bin

Actually any advice on how the expressions are formed would be great

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

热鲨 2024-07-15 17:15:03

交替:

syntax: glob
bin/**

Alternately:

syntax: glob
bin/**
你对谁都笑 2024-07-15 17:15:03

我做了一些实验,发现 Windows 上的正则表达式语法适用于以当前存储库开头的路径,其中反斜杠转换为斜杠。

因此,如果您的存储库位于 E:\Dev 中,hg status 将针对 foo/bar/file1.c 等应用模式。 锚点应用于此路径。

因此:

  • Glob 适用于路径元素并以元素部分为根
  • foo 匹配任何名为 foo 的文件夹(或文件)(不是“foobar”或“barfoo”)
  • *foo* 匹配名称中带有“foo”的任何文件夹或文件
  • foo /bar* 匹配“foo”文件夹中以“bar”开头的所有文件

  • 正则表达式区分大小写,不锚定
  • 当然,反斜杠正则表达式特殊字符如 . (点)
  • / 匹配 Windows 上的 \ 路径分隔符。 \ 与此分隔符不匹配...
  • foo 匹配 foo/ 中带有“foo”的所有文件和文件夹
  • 只匹配以“foo”结尾的文件夹
  • /foo/ 匹配路径中某处的文件夹“foo”
  • /foo/bar/ 匹配路径
  • ^foo 中的文件夹“foo”中的文件夹“bar”匹配存储库根目录下以 foo 开头的文件或文件夹
  • foo$ 匹配以 foo 结尾的文件

我希望这会有所帮助,我发现 HGIGNORE(5) 页面有点简洁。

I did some experiments and I found that the regex syntax on Windows applies to the path starting with the current repository, with backslashes transformed to slashes.

So if your repository is in E:\Dev for example, hg status will apply the patterns against foo/bar/file1.c and such. Anchors apply to this path.

So:

  • Glob applies to path elements and is rooted to element parts
  • foo matches any folder (or file) named foo (not to "foobar" nor "barfoo")
  • *foo* matches any folder or file with "foo" in the name
  • foo/bar* matches all files in "foo" folder starting with "bar"

  • Regex is case sensitive, not anchored
  • Of course, backslash regex special characters like . (dot)
  • / matches \ path separator on Windows. \ doesn't match this separator...
  • foo matches all files and folders with "foo" inside
  • foo/ matches only folders ending with "foo"
  • /foo/ matches the folder "foo" somewhere in the path
  • /foo/bar/ matches the folder "bar" in the folder "foo" somewhere in the path
  • ^foo matches file or folder starting by foo at the root of the repository
  • foo$ matches file ending with foo

I hope this will help, I found the HGIGNORE(5) page a bit succinct.

我不会写诗 2024-07-15 17:15:03

这两个都会过滤掉名为 cabin 的目录,这可能不是您想要的。 如果您要过滤顶级,则可以使用:

^/bin/

对于根目录下的 bin 目录,您可以省略 ^。 不需要指定语法,regexp 是默认的。

Both of those will also filter out a directory called cabin, which might not be what you want. If you're filtering top-level, you can use:

^/bin/

For bin directories below your root, you can omit the ^. There is no need to specify syntax, regexp is the default.

笨死的猪 2024-07-15 17:15:03

语法: 全局
bin/**

这个答案如上面所示,但我还想补充一点,* 和 ** 的处理方式不同。 ** 是递归的,* 不是。

请参阅Hg 模式

syntax: glob
bin/**

This answer is shown above, however I'd also like to add that * and ** are handled differently. ** is recursive, * is not.

See Hg Patterns

山色无中 2024-07-15 17:15:03

没关系,我知道

syntax: regexp
bin\\*

表达式遵循标准的 Perl 正则表达式语法。

Nevermind, I got it

syntax: regexp
bin\\*

expressions follow standard perl regular expression syntax.

你对谁都笑 2024-07-15 17:15:03

忽略 .class 文件

syntax: regexp
?\.class

to ignore .class files

syntax: regexp
?\.class
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文