Git忽略特定文件夹名称中具有特定扩展名的文件

时间:2015-03-26 01:43:33

标签: git gitignore

我正在使用git 1.9.5(Windows 7),并希望忽略某些特定文件夹名称中具有特定扩展名的文件。

例如:

A\Reports\fileA.docx
A\Reports\fileA.pdf
B\Reports\fileB.docx
B\Reports\fileB.pdf
C\Reports\fileC.docx
C\Reports\fileC.pdf

我尝试过Reports \ * .docx和Reports \ * .pdf,没有用。

我知道.gitignore可以放在每个文件夹中(例如A,B,C)。但是,我有很多文件夹报告,将来会创建更多。我试图在全局忽略文件中找到解决方案。

我怎样才能编写规则来忽略它们?

感谢您的任何建议。

1 个答案:

答案 0 :(得分:2)

使用以下模式:

**/Reports/*.docx
**/Reports/*.pdf

含义:

忽略所有目录(**),一个名为Reports(/Reports)的子目录目录,其中包含一个带有docx扩展名(/*.docx)的文件。

请注意,即使您处于Windows环境中,目录也会被正斜杠(/)分隔。

相关问题