/rm-node_modules

For demoing how to remove node_modules and add to a .gitignore after an accidental push

How to remove node_modules and prevent it from being pushed again after an accidental push

Instructions

  1. Create a .gitignore file if it doesn't exist already

touch .gitignore

  1. Add the line **/node_modules to the .gitinore file to prevent tracking
    The **/ a file or directory listed after the slash from being tracked no matter where it is in the repo

echo "**/node_modules" >> .gitignore

  1. Remove the currenty tracked node_modules

git rm -r --cached node_modules

  1. Add .gitignore

git add .gitignore

  1. Commit now that nodei_modules has been removed

git commit -m "removed node_modules and added it to the .gitignore"

  1. Push the changes

git push

Hooray!!!