I’ve found a weird problem in Git. I have a folder called cache under my Git structure that in the past (by mistake) wasn’t gitignored. The problem is that some commits ago I added this folder to the .gitignore file and now due to some cache changes I have noted that some files in this folder are not ignored. Why? How to ignore them definitivelly?
.gitignore line is as simple as:
cache/*
Adding something to the
.gitignoredoes not un-track the file. If you want to un-track the file without deleting it, usegit rm --cached file. This will remove the file from the index without removing it from the working tree (although you still need to commit this).It’s worth noting that, if you aren’t aware, .gitignore only applies to untracked files.