树形结构
这就是我的 Node.js 项目的组织方式:
/
| - node_modules [+ INCLUDE]
| | - my-mod1
| | | - node_modules [- IGNORE]
| | | | - external-mod1
| | | | - external-mod2
| | | - src
| | | | - node_modules [+ INCLUDE]
| | | | | - my-mod2
| | | | | - my-mod3
| | - my-mod4
我的计划
将我的项目发布到 GitHub 时:
- 我想包括
my-mods。 - 我不想包括
external-mods。
这意味着:
- 我想包含顶级
/node_modules文件夹。 - 我不想包含作为模块文件夹
node_modules的直接子文件夹的文件夹。 - 但我想包括
node_moduels文件夹的子src文件夹。
我做了什么
我将以下几行添加到/.gitignore:
#################
## npm
#################
npm-debug.log
node_modules/
!/node_modules/
!src/node_modules/
我的问题
我需要哪些.gitignore规则来包含正确的node_modules文件夹(如上所述)?
谢谢 - 如果有任何不清楚的地方,请发表评论。