Search code examples
gitcommitgitignore

How can I use .gitignore properly?


This is how my .gitignore file looks like:

/.env
/public/bundles/
/var/
/vendor/
/public/data/
/public/data/data.json

I added the data.json file later to the .gitignore file and now I have the problem that git does not accept the file as ignored. So whenever I make a change on the file, git is listing the file public/data/data.json in uncommited changes...


Solution

  • Whenever a file is already tracked by git, it will be that way no matter what .gitignore says. If you want to stop tracking it, try git rm --cached public/data/data.json. This will remove file from git, but not from the filesystem.