Search code examples
gitcsvgitignore

How do I get git to ignore my csv files?


I want git to ignore my csv files. But, when I do git status, I see that the csv is in "Changes not staged for commit". But, I swear I added it to the .gitignore file a while ago. In fact, when I look at the .gitignore file, I see that it is there!

*.csv

So, how to I get git to ignore my csv's? The problem is that I want to be able to do git reset and git checkout without having to worry about the csv files being overwritten in my working directory.


Solution

  • Looks like the problem is that, the csv files are already tracked in a commit before, so even though you add *.csv the git will start tracking the previously tracked files.

    You can solve this using git rm --cached option, discussed in detail in this stackoverflow question