I am trying to push my project to GitHub and Heroku. Since I am using Node.js in my app, I have folder node_modules. Before I commit I have created a file called .gitignore to ignore the Node.js modules.
Inside the file I have added folder node_modules and tried to push to the GitHub repository from the comandline/Terminal. I was not expecting the Node.js modules to be pushed, but they appeared finally in the repository. Is there an ways I have to follow?
Here is how I resolve my issue
- $ git rm -r --cached node_modules
Add folder node_modules/ to your .gitignore file:
- $ git commit -m "remove the ignored directory node_modules"
And then
- $ git push origin master
After that, if you refresh the GitHub page you will see the node_modules folder gone.
.gitignore, that file only provides rules forgit add. If you've already added them, you need different tools to get rid of them..gitignorewas already havenode_modulesto be ignored but for some reason when I pushed my code thenode_modulespushed together with the other code.