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.

101 ways to revert to your old code using Git

Git is a powerful tool to manage your project’s codebase. Chances you have to revert/ restore commits to get rid of bad codes, or some bugs that you can not find out; these are some cases that you may find yourself in most often:

Stage 1. Coded but haven’t git added yet:

Stage 2. Added ‘by accident’, but haven’t commited yet:

Stage 3. Commited, but ‘luckily’ haven’t pushed yet:

Stage 4. Commited, pushed, “saddo”!

Pushed = somebody pulled and got that code. You could not just come there and say ‘Hey, delete your code you just pulled‘. Instead, you just say ‘I did the wrong thing, get this instead!‘.

The thing to do now is to push another commit, the content is the revert of current commit:


As you can see, git is an important and a powerful tool to work with that fastens your development and makes life easier.