Home > Back-end >  When using github do include everything then ignore node_modules or install your apl then pull?
When using github do include everything then ignore node_modules or install your apl then pull?

Time:06-18

Ive started using github. Ive read that you should not include node_modules. So how would this work if I need to pull? For example with svelte. Should I include everything in the initial commit including the svelte and node_modules directories then clone and ignore them on subsequent pulls? Or install a fresh version then just pull the added files?

CodePudding user response:

When you've tracked a file, .gitignore no longer applies to those tracked files as long as they're tracked. So if you add your node_modules in the first commit and then add it to .gitignore, it won't be ignored, and it will be tracked in this history.

In general, you should set up your .gitignore to exclude node_modules and anything else you don't want to include before your initial commit, and you should be careful to add additional things to .gitignore as necessary so as to not commit files at all that you don't want in the repository.

Note that Git doesn't provide a way to ignore tracked files at all. If they are tracked, changes will be reflected in the working tree.

  • Related