alex alex - 1 month ago 4
Git Question

Git warning about file change even if the file is being ignored?

For example, if I want to change a branch

git checkout testing
), I'll get this warning:

error: Your local changes to the following files would be overwritten by checkout:

But as you can see, the file is being ignored:

enter image description here

Why is this happening?


It seems that the file was being tracked before so you need to explicitly remove it once, by this command:

git rm --cached <file>

This is related to this topic: How to make Git "forget" about a file that was tracked but is now in .gitignore?