gitignore not ignoring file 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: Force add despite the .gitignore file
git add --force my/ignore/file.foo
Example 4: Why doesn't Git ignore my specified file?
In order to actually ignore the file, you have to untrack it and remove it from the repository. You can do that by using git rm --cached sites/default/settings.php. This removes the file from the repository without physically deleting the file (that’s what the --cached does). After committing that change, the file will be removed from the repository, and ignoring it should work properly.