首页 > 解决方案 > How to ignore a folder except one subfolder in Mercurial

问题描述

I'm using Mercurial and I would like to ignore all folders named 'build' (I have two of these), with one exception - I would like to include the folder 'build/outputs/mapping/release'

I tried to add 'build/*' to .hgignore and manually add the subfolder to my repository it using hg add build/outputs/mapping/release but it didn't work.

Any idea how can I do it in my .hgignore file?

标签: androidregexmercurialbitbuckethgignore

解决方案


Git 支持“取消忽略”之前列出的忽略条目的概念,后面的条目会覆盖之前的条目。Mercurial 没有,因此您必须想出涵盖您的情况的表达式。

您提到您有两个特定的目录要忽略,因此您可以简单地列出它们,而不是使用模式:

^build/ignore1/
^build/ignore2/

例如。对于更复杂的情况,您可以将它们全部枚举,或者提出与所需路径匹配的模式,就像您在评论中所做的那样。


推荐阅读