忽略文件名中不包含“.example.js”的文件 .gitignore

Ignore files that do not contain ".example.js" in their file names .gitignore

我有以下 situation.I 有一个名为 configs 的文件夹。 在里面我有一些包含单词“.example.js”的文件。现在我想为这个目录做的是忽略不包含“.example.js”,[=18=的文件]

例如考虑 foo.example.jsfoo.js。我想忽略 foo.js 我只是不在我的 .gitignore 中添加 foo.js 的原因是在该目录中可能有更多不包含 .example.js 的文件,例如 secrets.jssettings.js。有什么办法吗?

我假设 config 文件夹位于您存储库的根文件夹中。

尝试将以下两行添加到您的 .gitignore:

/config/*
!/config/*.example.js