2013-03-28 429 views

回答

27

如图所示here并详细描述在“this question”中,函数fnmatch()涉及解释glob模式,这意味着不支持正则表达式。

这是gitignore man page提到:

否则,git treats the pattern as a shell glob suitable for consumption by fnmatch(3)FNM_PATHNAME标志:在模式通配符不匹配的路径名/
例如,“Documentation/*.html”与“Documentation/git.html”匹配,但不匹配“Documentation/ppc/ppc.html”或“tools/perf/Documentation/perf.html”。

您可以在thosequestions中看到glob模式与正则表达式之间的某些对应关系。

8

.gitignore(和其他)文件使用文件名globs,而不是正则表达式。

我非常怀疑你可以说服git黑客改变这种情况:到现在为止根深蒂固,而且globs比作为文件名匹配者更为熟悉。

+10

很遗憾。这样一个方便的功能可以。 – 2014-04-17 08:02:31

+3

@ArturBarseghyan,考虑Mercurial,它有这个整洁的功能和许多其他很酷的功能。 – toriningen 2015-04-04 20:46:33

+0

@modchan:我知道它存在于Mercurial中,我使用它很多。无论如何感谢您的评论。 – 2015-04-07 14:29:51

相关问题