Skip to content

Instantly share code, notes, and snippets.

@nuggetnchill
Last active March 8, 2024 15:36
Show Gist options
  • Save nuggetnchill/ca2768b1ea956d7374384c4d67e33b6e to your computer and use it in GitHub Desktop.
Save nuggetnchill/ca2768b1ea956d7374384c4d67e33b6e to your computer and use it in GitHub Desktop.
Removing node_modules when you forget to add .gitignore file

How to remove node_modules

  1. Create a .gitignore file in the git repo if it doesn't have one

touch .gitignore

  1. Open up the .gitignore and add the following line to the file

/node_modules

  1. Remove the node_modules folder from the git repository

git rm -r --cached node_modules

  1. Commit the git repository without the node modules folder

git commit -m "Removed node_module folder"

  1. Push the repository to github

git push origin master

Don't forget to add the gitignore and commit it to the repo

git add .gitignore

git commit -m "Added .gitignore file"

git push origin master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment