Ivan
Ivan

Reputation: 15912

Git "remembers" old not-ignored files

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/*

Upvotes: 1

Views: 485

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185661

Adding something to the .gitignore does not un-track the file. If you want to un-track the file without deleting it, use git 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.

Upvotes: 4

Related Questions