I created an angular project and pushed it in my github
repository.
When I looked at the pushed files, the node_modules
folder was missing, I didn't declare anywhere to ignore this folder, is this a default behavior? If yes then why?
Also, when I decided to delete all my repositories on github and create only one instead where I will check-in all my projects, once initializing git init
and pushing changes, git started pushing node_modules
folder for all projects and it took a lot of time.
What makes git
ignore or not ignore the node_modules
folder all by itself? I haven't set this configuration anywhere by myself.
Thank you.
git
does not ignore node_modules
by default. It ignores nothing by default. The angular cli adds node_modules
to .gitignore
, which caused git
to ignore it. See https://stackoverflow.com/a/37187110/5666087 for more info, and see angular cli's github repo for the specific .gitignore file added. You will see that /node_modules
is listed there.
You should not version control node_modules
, because those are artifacts you can get easily with npm install
or yarn install
.
Creating a git repository outside of a angular project (e.g., in a new directory) does not add a .gitignore
file, so node_modules
is not ignored.