3

enter image description here The image says it all. Why is git telling me that I've changed the file when I'm explicitly telling it to ignore it?

frankelot
  • 13,666
  • 16
  • 54
  • 89
  • 1
    possible duplicate of [Making git "forget" about a file that was tracked but is now in .gitignore](http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – 1615903 Sep 24 '15 at 05:01

3 Answers3

5

A .gitignore specifies files that should not be added to git's index. It does not prevent changes to files that are already in the index.

If you want to remove the file completely from the index, you will need to commit a deletion of that file. Then if the file gets recreated (and it is still listed in .gitignore), it will not be re-added to the index.

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
3

you have to remove it from the repository and then commit it.

git rm -rf --cached .idea/*
git add -A .
git commit -m "Removed idea files"
git push

And now all your .idea files will be ignored (if added to the .gitignore as described above).

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
1

You may have added the file previously, making it tracked. If it gets added to the .gitignore file after that, Git will still report changes to it because it is a tracked file.

You need to remove the file from the index and create a new commit.

Greg Hurrell
  • 5,177
  • 23
  • 27