Search code examples
gitgitignore

git does not ignore directory even though it is in .gitignore file


git status prints the following:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   .gitignore
    new file:   app.js
    new file:   dev1/test.js
    new file:   dev2/test.js
    new file:   git
    new file:   log.txt

content of .gitignore file:

   hell.txt
   /dev1

After adding my whole content of the file, it is uploaded even the file hell.txt as well as dev1 folder too Also run the file in notepad, No issue of encoding Also, I double checked this fact, first I included gitignore file then I included all the file.


Solution

  • You have already staged dev1/test.js, that's why it's not being ignored. Use git reset HEAD dev1/test.js to unstage it.