How to remove node_modules from github or bitbucket

featured Image

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:

  1. Create a .gitignore file
  2. Remove the node_modules folder
  3. 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 .gitignore file.

If you don’t, you have to create a .gitignore file in the root directory.

touch .gitignore

2. Remove the node_modules folder

Next, we have to add the node_modules folder in the .gitignore file.

Open the .gitignore file and add the following line in the file.

node_modules/

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 node_modules folder.

git add .
git commit -m "remove node module folder"

Then push the code to your remote branch

git push origin master

Related Topic:

How to add an empty folder/directory in Git

Resolve- Refusing To Merge Unrelated Histories Git Error

Open Github Repository Directly In Vscode In Browser Online

How to change git username and password on PC

How to change image size in markdown in GitHub

How to save username, email and password globally in Github?

How to check Git email address and username in terminal?

Checkbox inside GitHub Markdown Table

Related Posts

git commands with example

Top 40 Git commands with Examples

GitHub has become an essential tool for developers to manage, store, and collaborate with other developers on software projects. With its simple powerful git-based version control system, GitHub allows users…

Read more
Check GitHub Account in the Terminal

Check GitHub Account in the Terminal

GitHub is an integral tool for developers to store, manage, and collaborate on software projects with other developers. And as we work more and more in the command line it…

Read more
featured Image

How to make list of objects in Netlify CMS using list and object Widget

Here in this Netlify CMS tutorial we will how easily we can make a list of objects using list and object widgets. This will allow us to add multiple objects…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *