.gitignore is not ignored by node_modules / folder
I'm trying to get git to ignore my files in node_modules / and it doesn't seem to accept this change.
Here is the content of my file .gitignore
:
node_modules/
and here is my project structure:
I would expect the node_modules folder and all files / folders in it to be ignored by git, but instead I get a whole ton of changes listed as pending and even when I make the git state at the root node_modules / appears as pending. Is there some kind of nomenclature on Windows that makes git weird?
source to share
Just add /
before node_modules/
should be like
/node_modules/
# ^ forward slash before the folder name signifies root dir
If you only want to exclude certain files in the node_modules folder, you can also do something like /node_modules/*.json
to exclude all files inside the root node_modules folder with the extension .json
.
source to share