.gitignore not ignoring the files specified.

I have updated the .gitignore file with the entry /app/etc/config.php
Then i pulled this .gitignore file onto my server
Then when i change the app/etc/config.php file and push it to github, it still accepts and pushes it to repository!!!

Then i make a change in github directly on this file and do a pull on local system, it downloads this updated file!!!

What am i missing?


A .gitignore file only affects untracked files that you don’t want to add to the repository.

It seems to me that /app/etc/config.php is already tracked in your repository. In that case pushing and pulling changes to it will not be affected by the .gitignore file, see also: https://git-scm.com/docs/gitignore

If you didn’t want to add this file to the repository, you can use git rm --cached to remove the file from the index, but keep it around locally.