如何从 .gitignore 子文件夹中排除所有扩展名(但不包括 PHP 和 JS)?

How to exclude all extensions (but not PHP and JS) from .gitignore sub-folder?

我想在 .gitignore 中排除:

我试过了,但它也允许在管理员中使用:

**/admin
**/content
!.php
!.js

您是否尝试过为每个 "special" 文件夹使用不同的 .gitignore?

尝试忽略文件夹(afolder/ 带尾部斜杠),但将文件夹文件列入白名单 (afolder/*):

admin/
content/*
!content/subfolder/**/*.php
!content/subfolder/**/*.js

content/ 文件夹中添加专用的 .gitignore 是另一种选择,但那样的话,您可以将所有忽略规则集中在 one .gitignore 文件位于主存储库的根文件夹中。

像往常一样,检查应用了什么规则:

git check-ignore -v -- a/file