If you have added node_modules/ to your .gitignore file at a moment where your existing directory was already tracked in git, you need one extra step to make git "forget" about this directory:
I have also faced same issue some time back. In my case after, updated the .gitignore after making commit into repo. So below are the steps i have followed up to resolve same –
Step 1 – Commit all your changes into repo.
Step 2 – Refresh your git repository index by running below command. git rm -r –cached
Step 3 – Add everything back using git add .
Step 4 – Finally commit your changes like git commit -m ".gitignore fix"
Now you won’t see node_modules coming into changes.
It looks like you have already added some files from node_modules folder in your repo (otherwise the color of the node_modules folder would be green instead of brown)
You can look which files are tracked in your repo using this
git ls-tree --full-tree --name-only -r HEAD
And you can remove a directory from git using this
3
Answers
If you have added
node_modules/
to your.gitignore
file at a moment where your existing directory was already tracked in git, you need one extra step to make git "forget" about this directory:I have also faced same issue some time back. In my case after, updated the .gitignore after making commit into repo. So below are the steps i have followed up to resolve same –
Step 1 – Commit all your changes into repo.
Step 2 – Refresh your git repository index by running below command.
git rm -r –cached
Step 3 – Add everything back using git add .
Step 4 – Finally commit your changes like git commit -m ".gitignore fix"
Now you won’t see node_modules coming into changes.
It looks like you have already added some files from node_modules folder in your repo (otherwise the color of the node_modules folder would be green instead of brown)
You can look which files are tracked in your repo using this
And you can remove a directory from git using this
And don’t forget to commit changes after that.