我有一个项目包含多个其他项目:

主要项目 小项目1 小项目2

所有包含node_modules文件夹。我想要git忽略文件夹,无论它是从根文件夹开始的位置。在.gitignore中添加如下内容:

*node_modules/*

当前回答

在.gitignore中添加下面的行将忽略整个存储库中的节点模块。

node_modules

其他回答

在Mac,

打开sourcetree 点击特定项目 点击设置 单击高级 点击编辑gitignore 写“node_modules” 并保存。

只需在小项目1和小项目2中添加不同的.gitignore文件。每个.gitignore文件都应该/node_modules,这样就可以了。

如果你的子项目/客户端node_modules被提交,

    # dependencies
    /node_modules
    /.pnp
    .pnp.js

    # testing
    /coverage

    # production
    /build

    # misc
    .DS_Store
    .env.local
    .env.development.local
    .env.test.local
    .env.production.local

    npm-debug.log*
    yarn-debug.log*
    yarn-error.log*

然后在最后一行添加“node_modules”。

    # dependencies
    /node_modules
    /.pnp
    .pnp.js

    # testing
    /coverage

    # production
    /build

    # misc
    .DS_Store
    .env.local
    .env.development.local
    .env.test.local
    .env.production.local

    npm-debug.log*
    yarn-debug.log*
    yarn-error.log*
    node_modules 
    # ------ Up Here ------

在.gitignore中添加下面的行将忽略整个存储库中的节点模块。

node_modules

将node_modules/或node_modules添加到.gitignore文件中,以忽略当前文件夹中所有名为node_modules的目录和任何子文件夹。