Answers:
加上这个
node_modules/
到.gitignore文件忽略所谓的所有目录node_modules当前文件夹和子文件夹中
在项目目录的终端中使用通用单线:
触摸.gitignore && echo“ node_modules /” >> .gitignore && git rm -r-缓存的node_modules; git状态
无论您是否创建了.gitignore它,无论是否添加node_modules到git跟踪中,它都有效。
然后提交并推送.gitignore更改。
说明
touch.gitignore如果尚不存在,将生成文件。
echo并且>>将追加node_modules/在结尾.gitignore,造成node_modules文件夹和子文件夹都将被忽略。
git rm -r --cachednode_modules从git控件中删除该文件夹(如果之前已添加)。否则,这将显示警告pathspec 'node_modules' did not match any files,没有副作用,您可以放心忽略。这些标志导致删除是递归的,并且包括缓存。
git status显示新的更改。.gitignore将出现一个更改,而node_modules不会出现,因为不再被git跟踪。
touch这里不需要的:>>如果文件不存在,将创建该文件。
touch是必需的。否则>>将返回no such file or directory: .gitignore。
echo "node_modules/" > .gitignore应该使用原始内容创建新文件,方法是>> 将文本追加到现有指定文件的末尾
尝试做这样的事情
**/node_modules
** 用于整个项目中的递归调用
**模式中与完整路径名匹配的两个连续星号可能具有特殊含义:前导
**后跟斜杠表示在所有目录中均匹配。例如,在任何地方都**/foo匹配文件或目录foo,与pattern相同foo。**/foo/bar匹配文件或目录bar直接位于目录下的任何位置foo。拖尾
/**匹配内部的所有内容。例如,abc/**相对于abc.gitignore文件的位置,将目录内的所有文件深度无限匹配。斜杠后跟两个连续的星号,然后斜杠匹配零个或多个目录。例如,
a/\**/b比赛a/b,a/x/b,a/x/y/b等等。其他连续的星号被视为无效。
node_modules/?
首先,最重要的是.gitignore在my-app中添加文件。如下图所示。
然后将其添加到您的.gitignore文件中
/node_modules
您也可以添加其他文件,以忽略它们被推送到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*
通过代码编辑器或命令直接在根文件夹中创建.gitignore文件
对于Mac和Linux
触摸.gitignore
对于Windows
回声.gitignore
打开.gitignore声明这样的文件夹或文件名/ foldername
将以下行添加到您的.gitignore
*/node_modules/*
这将忽略当前目录以及子目录中的所有node_modules。
您也可以使用SVN / Tortoise git来完成。
只需右键单击node_modules-> Tortoise git->添加以忽略列表。
这将为您生成.gitIgnore,并且您不会在暂存中再次找到node_modules文件夹。