我有一个项目包含多个其他项目:
主要项目 小项目1 小项目2
所有包含node_modules文件夹。我想要git忽略文件夹,无论它是从根文件夹开始的位置。在.gitignore中添加如下内容:
*node_modules/*
我有一个项目包含多个其他项目:
主要项目 小项目1 小项目2
所有包含node_modules文件夹。我想要git忽略文件夹,无论它是从根文件夹开始的位置。在.gitignore中添加如下内容:
*node_modules/*
当前回答
在Mac,
打开sourcetree 点击特定项目 点击设置 单击高级 点击编辑gitignore 写“node_modules” 并保存。
其他回答
添加以下行到你的。gitignore
/ node_modules /
在我的例子中,在没有使用前睫毛的情况下写入/node_modules是无效的
**node_modules
这对我很有用
递归方法忽略子文件夹中存在的所有node_modules
首先也是最重要的事情是在我的应用程序中添加。gitignore文件。如下图所示。
然后把这个添加到你的。gitignore文件中
/node_modules
Note
你也可以添加其他文件,忽略他们被推到github上。以下是一些保存在。gitignore中的文件。你可以根据你的要求添加。#只是在.gitignore文件中注释的一种方式。
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# 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”。
# 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 ------
敌人谁是尝试上述答案,仍然面临的问题
我已经尝试了几乎所有的答案,最终,它解决了我忽略node_modules的问题,但只有在我提交更改之后!