Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get git to ignore my csv files?

Tags:

git

gitignore

csv

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.

like image 552
makansij Avatar asked Oct 16 '15 16:10

makansij


People also ask

How do I set Git to ignore files?

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.

Why is Git not ignoring files?

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).

What files Git ignore?

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.


1 Answers

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

like image 194
Sharath Bhaskara Avatar answered Oct 16 '22 21:10

Sharath Bhaskara