Mercurial 忽略除特定文件名之外的所有文件

发布于 2025-01-05 22:22:40 字数 176 浏览 4 评论 0原文

我有一个大型文件系统,其中几乎每个文件夹都有一个名为 content.txt 的文件,

我想跟踪每个名为 content.txt 的文件并自动忽略其他所有文件。我希望存储库自动跟踪名为 content.txt 的新文件,因此我不想忽略 .hgignore 中的所有内容,然后手动添加。

有人知道该怎么做吗?

I have a large file system in which almost every folder has a file called content.txt

I want to track every file named content.txt and automatically ignore everything else. I want the repo to automatically track new files named content.txt so I don't want to ignore everything in the .hgignore and then manually add.

Anyone know how to do this?

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

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

发布评论

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

评论(2

北渚 2025-01-12 22:22:40
  1. 它必须是 regexp 模式,而不是 glob
  2. 您必须调试 regexp 的路径部分,但“除 content.txt 之外的所有内容”草稿是 re:.*\.(?!content.txt ) 希望

替代解决方案可以是
* 忽略所有
* 将 content.txt 文件模式添加到提交命令(-I 选项),请参阅 hg help commithg help 模式

hg commit -I '**content.txt txt'

编辑

re:.*/(?!content.txt)

  1. It has to be regexp mode, not glob
  2. You must debug path-part of regexp, but "all except content.txt" draft is re:.*\.(?!content.txt) as hope

Alternative solution can be
* ignore all
* add content.txt files pattern to commit command (-I option), see hg help commit and hg help patterns

hg commit -I '**content.txt'

Edit

re:.*/(?!content.txt)

捂风挽笑 2025-01-12 22:22:40

试试这个:

syntax: regexp
\.(?!txt$)[^.]+$ # "*." is followed by "txt" and we're at the end
(?<!\.)txt$ # "txt" follows a "."
(?<!/)content\. # "content." follows path separator
(?<!content)\. # "." follows "content"

我留下了我在实验时所做的评论,以理解这一切。 (这是第一个中的 glob 语法。)

Try this:

syntax: regexp
\.(?!txt$)[^.]+$ # "*." is followed by "txt" and we're at the end
(?<!\.)txt$ # "txt" follows a "."
(?<!/)content\. # "content." follows path separator
(?<!content)\. # "." follows "content"

I left in the comments I made while experimenting, to make sense of it all. (That's glob syntax in the first one.)

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