git ignores node_modules folder
During development, if you don't want to track many changes in your node_modules file, you can create a .gitignore
file that tells git to ignore that folder.
ignore the node_modules folder in the root folder
file structure:
.
|
├── node_modules
├── src
├── .gitignore
.gitignore 文件放在最外层,与node_modules同级
.gitignore 中提到的文件/文件夹不会被 git 跟踪
。
So to ignore node_modules, the contents of the .gitignore file should be as follows:
node_modules
Ignore all node_modules folders present in the whole project
file structure:
.
├── AAA
│ ├── index.html
│ └── node_modules
├── BBB
│ ├── index.html
│ └── node_modules
└── .gitignore
There are two node_modules folders in the AAA and BBB folders, and only one .gitignore file in the project root. To ignore both node_modules folders, the content of the .gitignore folder must be:
**/node_modules
Here, two consecutive asterisks ** followed by a slash / match in all directories to match the node_modules folder in the AAA and BBB folders. So this will make Git ignore both node_modules folders.