简体   繁体   中英

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.

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.

I understand the .gitignore could be put in each folder (eg 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 ).

Notice that the directories are separated by forward slashes ( / ) even though you are in a Windows environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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