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.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
gitignore just ignores files that have not yet been added to the repository. If you have already git added certain files, their modifications will be tracked. Use git rm -r --cached on such files to delete them from your repository (but not from your file system).
gitignore should contain all files that you want to ignore. Therefore, you should ignore files generated by the OS, the IDE you are working on... My question appears when the repository is on Github and people can clone it and push the changes. These people can use other operating systems and can use other IDEs.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With