如何让 git 忽略我的 csv 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33175721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get git to ignore my csv files?
提问by Candic3
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!
我想让 git 忽略我的 csv 文件。但是,当我这样做时git status
,我看到 csv 在"Changes not staged for commit"
. 但是,我发誓我不久前将它添加到 .gitignore 文件中。事实上,当我查看.gitignore
文件时,我看到它就在那里!
*.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.
那么,如何git
忽略我的 csv 呢?问题是我希望能够这样做git reset
并且git checkout
不必担心csv
我的工作目录中的文件被覆盖。
采纳答案by Sharath Bhaskara
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.
看起来问题在于,csv 文件之前已经在提交中跟踪过,因此即使您添加*.csv
git 也会开始跟踪以前跟踪过的文件。
You can solve this using git rm --cached
option, discussed in detail in this stackoverflow question
您可以使用git rm --cached
选项解决此问题,在此 stackoverflow question中详细讨论
回答by KIT
It should add *.csv
in your .gitignore file and after that use git rm --cached *.csv
to remove all existing csv files from your git repository
它应该添加*.csv
到您的 .gitignore 文件中,然后用于git rm --cached *.csv
从您的 git 存储库中删除所有现有的 csv 文件