Remove node_modules folder from your git repo

Today I pushed my project onto GitHub but yet forgot to add node_modules to .gitignore file. I am pretty sure that everybody has found themselves in such circumstances, at least once during his/ her developer’s life.

Today I’m going to note down the commands that help removing the node_modules or any other files/ folders that you mis-pushed.

First of all, add this line to your .gitignore:

Second, run your favorite Terminal and type these commands:

With these steps, you’ve now got rid of the annoying node_modules (or any other file/ folders) from your repo.

Leave a Reply