1

Should not this entry in .gitignore make GIT ignore it?

*.cache

The file is in a subdir, ".firebase". The file shows up in "SOURCE CONTROL: GIT" in vscode as "Modified". (In Windows 10.)

EDIT: My problem was that I did not know that .gitignore does not work on tracked files.

Leo
  • 4,136
  • 6
  • 48
  • 72
  • 2
    If the file is already tracked, .gitignore will make no difference. Is that the case? Is the file part of HEAD revision already? – eftshift0 Mar 26 '19 at 14:38
  • Sounds like that could be the case. I might have used some convenience function in vscode that started the tracking. I am not using GIT often. How do I see if the file is tracked? – Leo Mar 26 '19 at 14:40
  • 1
    `git ls-tree -r HEAD | grep filename`. (replace filename). If the filename does show up there, then it's tracked. – eftshift0 Mar 26 '19 at 14:43
  • Thanks, yes it is tracked. Seems like a lot of people has this trouble, but which solution is best?? https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore – Leo Mar 26 '19 at 14:50
  • 1
    Possible duplicate of [How to make Git “forget” about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore). – Romain Valeri Mar 26 '19 at 14:55
  • Not really a duplicate since I did not know about tracked files vs .gitignore. (That was a bit surprising to me. Why does not git have a simple solution to this?) – Leo Mar 26 '19 at 15:01
  • BTW, my solution was to move the file to another directory, commit and then move the file back again. – Leo Mar 26 '19 at 15:06
  • 1
    If you want the file out of your history (as if it was never ever added in the first place), you might have to consider rewriting history. – eftshift0 Mar 26 '19 at 16:16

0 Answers0