How to remove node_modules from github or bitbucket
📋 Table Of Content
In this post, we will see how to remove node_modules folder from our repo in Github and bitbucket.
If you have accidentally pushed your
node_modules folder to a remote repository on git, then deleting it locally before your next push, will not delete the folder from the remote repo on Github.
So how can we remove it?
To remove it we have to follow these steps:
- Create a .gitignore file
- Remove the node_modules folder
- Commit all change to github or bitbucket
Let's follow each step in detail
1. Create a .gitignore file
First, check in your project's root folder if you have a
If you don't, you have to create a
.gitignore file in the root directory.
2. Remove the node_modules folder
Next, we have to add the
node_modules folder in the .gitignore file.
.gitignore file and add the following line in the file.
Now, remove/delete the
node_modules folder from the project folder. To do that, run this command
git rm -r --cached node_modules
Or you can run this too
git rm -r --cached .
3. Commit all changes to git
Now, you can commit the local repository to git without the
git add . git commit -m "remove node module folder"
Then push the code to your remote branch
git push origin master
How to add an empty folder/directory in Git