gitignore 所有 node_modules 目录和子目录

gitignore all node_modules directories and subdirectories

如果我把它放在 .gitignore 中:

node_modules

它似乎没有忽略包含 node_modules 文件夹的子目录。 所以我猜这会起作用:

*/node_modules/

有谁知道忽略文件以忽略匹配子文件夹的正确语法是什么?

您确实可以忽略子目录,并且您提出的语法是正确的,这是我正在使用的 .gitignore 的工作示例:

# Bundler
Gemfile.lock
bin/*
.bundle/*
*/test/