I started a project using npm, added a few dependencies and then initialized the repository usign git init
.
I wanted the directory node_modules
to be ignored by git, so I added it to the .gitignore
file like so.
.gitignore
node_modules/
Of course because node_modules
was added before git init
, it is still recognized as a directory to track.
So I deleted it, used the following commands (as suggesed for similar problems)
git rm -r --cached .
git add .
git commit -m ".gitignore should now work"
Then reinstalled the npm dependencies by using npm install
After this I expect to have the directory node_modules
to be finally ignored.
Instead if I type git status
I get
Untracked files:
(use "git add <file>..." to include in what will be committed)
node_modules/
Why?