Tell Git to ignore the node_modules directory when pushing to remote repository?

Answered
nick asked this question 1 year, 6 months ago
nick on Dec 6, 2021 · Edited

When I push code to my git remote repository, how do I tell Git to complete ignore the node_modules directory? And to not have its contents pushed to GitHub?

The node_modules directory is way too big to store on GitHub!

1 suggested answers
looper003 on Dec 7, 2021

Add a .gitignore file to the root of your project directory:

touch .gitignore

And then add this line of code to the .gitignore file:

/node_modules

That will tell Git to ignore that folder when pushing updates to the remote repository.

You can read more about the .gitignore file here.

0 replies
Answered