.gitignore对我不起作用;试图忽略所有目录中的.csv文件

huangapple go评论57阅读模式
英文:

.gitignore not working for me; trying to ignore all .csv files in all directories

问题

I've read lots of posts already, and I've tried what I've found (ie creating my .gitignore file with the SINGLE LINE *.csv within the root directory (ie the same directory containing the .git folder (that's the root directory, right?), then running git rm -r --cached . followed by git add . followed by git commit -m "so tired of trying to ignore all csv files" followed by git push origin master. And yet, I still get many errors, all looking like:

remote: error: File zz_prep_stuff/z_csv_table_data/blah.csv is 485.89 MB; this exceeds GitHub's file size limit of 100.00 MB

So, clearly, something is wrong! Again, my .gitignore file contains only the following code:

*.csv

Please advise! Where am I going wrong? How do I ignore ALL csv files in my project? Thank you

英文:

I've read lots of posts already, and I've tried what I've found (ie creating my .gitignore file with the SINGLE LINE *.csv within the root directory (ie the same directory containing the .git folder (that's the root directory, right?), then running git rm -r --cached . followed by git add . followed by git commit -m "so tired of trying to ignore all csv files" followed by git push origin master. And yet, I still get many errors, all looking like:

remote: error: File zz_prep_stuff/z_csv_table_data/blah.csv is 485.89 MB; this exceeds GitHub's file size limit of 100.00 MB

So, clearly, something is wrong! Again, my .gitignore file contains only the following code:

*.csv

Please advise! Where am I going wrong? How do I ignore ALL csv files in my project? Thank you

答案1

得分: 2

但是... 如果blah.csv过去已经提交到你的代码库,即使你将其添加到.gitignore文件中,Git仍然会跟踪它。.gitignore文件只会忽略未跟踪的文件,不会忽略已经提交到代码库的文件。

你应该使用git filter-repo(首先需要安装)来从你的历史记录中清除那些.csv文件(注意:先备份你的代码库):

git filter-repo --path-glob '*.csv' --invert-paths
git push origin --force --all

这是基于路径的过滤

英文:

> And yet, I still get many errors,

But... if blah.csv has been committed to your repository in the past, it would still tracked by Git even if you add it to the .gitignore file.
The .gitignore file only ignores untracked files and does not ignore files that have already been committed to the repository.

You should use git filter-repo (to be installed first) in order to purge those .csv files from your past history (note: backup your repository first):

git filter-repo --path-glob '*.csv' --invert-paths
git push origin --force --all

It is using a Filtering based on paths.

huangapple
  • 本文由 发表于 2023年5月18日 07:13:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276753.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定