简体   繁体   English

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

[英]Git ignore files with particular extension in a particular folder name

I am using git 1.9.5 (Windows 7) and want to ignore some files with particular extension in a particular folder name. 我正在使用git 1.9.5(Windows 7),并且要忽略某些在特定文件夹名称中具有特定扩展名的文件。

for example: 例如:

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

I have tried Reports\\*.docx and Reports\\*.pdf, didn't work. 我已经尝试过Reports \\ *。docx和Reports \\ *。pdf,但是没有用。

I understand the .gitignore could be put in each folder (eg A, B, C). 我知道.gitignore可以放在每个文件夹中(例如A,B,C)。 However, I have many folders Reports and will create more in the future. 但是,我有许多文件夹“报告”,并且将来会创建更多文件夹。 Am trying to find a solution in the global ignore file. 我正在尝试在全局忽略文件中找到解决方案。

How could I write rules to ignore them? 如何编写规则以忽略它们?

Thanks for any suggestions. 感谢您的任何建议。

Use the following pattern: 使用以下模式:

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

What it means: 这是什么意思:

Ignore in all directories ( ** ), a sub-directory directory named Reports ( /Reports ), containing a file with a docx extension ( /*.docx ). 在所有目录( ** )中,忽略名为Reports( /Reports )的子目录目录,其中包含带有docx扩展名的文件( /*.docx )。

Notice that the directories are separated by forward slashes ( / ) even though you are in a Windows environment. 请注意,即使您在Windows环境中,这些目录也由正斜杠( / )分隔。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM