gitignore does not ignore folder

This solved it

I had done echo node_modules >> .gitignore and it didn't work.

the windows terminal from saves the file in UCS-2 LE BOM and git doesn't seem to accept that.

I opened the file with Notepad and saved with UTF-8 encoding

notepad save utf-8 encoding

It Works now.

I think they need to fix this since echo "filetoignore" >> .gitignore actually seems a handy thing to do


For me, the accepted answer was part of the solution, not the entire solution. Maybe, the other steps that I'm about to post were obvious, but I missed them first. Here's the steps I took to ensure my .gitignore file ignored the folder I wanted it to ignore:

  1. Commit any changes that you need to fix/change.
  2. Run this command: git rm -r --cached . (which removes everything from the git index in order to refresh your git repository)
  3. Then run this command: git add . (to add everything back to the repo)
  4. Finally, commit these changes using git commit -m ".gitignore Fixed"

You can find the link to the article from where I found the solution here.


I'm guessing this folder has been checked into git before?

Run git rm -r --cached <folder> and check again.

Tags:

Git

Gitignore