git ignore files but not directory code example

Example 1: .gitignore file not ignoring the file

git rm -r --cached .
git add .
git commit -m “.gitignore is now working”

Example 2: git ignore file is not working

git rm -rf --cached .
git add .

Example 3: gitignroe remove folder

git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"'
git push origin master

Example 4: how to put files into gitignore

$ echo debug.log >> .gitignore
$ git rm --cached debug.log
rm 'debug.log'
$ git commit -m "Start ignoring debug.log"

Tags:

Misc Example