Git lfs - "this exceeds GitHub's file size limit of 100.00 MB"

Git lfs - "this exceeds GitHub's file size limit of 100.00 MB"

我有一些 csv 文件大于 github 的文件大小限制 100.00 MB。我一直在尝试使用 Git 大文件存储扩展。

https://git-lfs.github.com/

来自 LFS - "Large file versioning- Version large files—even those as large as a couple GB in size—with Git."

我已将以下内容应用于相关文件夹:

git lfs track "*.csv"

然而,当我推送时:

remote: error: File Time-Delay-ftn/Raw-count-data-minor-roads1.csv is 445.93 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File Time-Delay-ftn/Raw-count-data-major-roads.csv is 295.42 MB; this exceeds GitHub's file size limit of 100.00 MB

当我查看有问题的文件夹时:

-rw-r-----   1 user  staff    42B 23 Oct 12:34 .gitattributes
-rw-r--r--   1 user  staff   1.3K 19 Oct 14:32 DfT_raw_major_manipulation.py
-rw-r--r--   1 user  staff   1.2K 16 Oct 15:08 DfT_raw_minor_manipulation.py
drwxr-xr-x  21 user  staff   714B 22 Oct 11:35 Driving/
-rwxr-xr-x@  1 user  staff   295M 19 Oct 14:47 Raw-count-data-major-roads1.csv*
-rwxr-xr-x@  1 user  staff   446M 16 Oct 14:52 Raw-count-data-minor-roads1.csv*

当我 vim .gitattributes 文件时,您可以看到 lfs 设置:

*.csv filter=lfs diff=lfs merge=lfs -text

我做错了什么?

更新

当我查询时

git lfs ls-files

我没有得到任何回报。这表明尽管 .csv 过滤器已成功应用于 .gitattributes 文件,但 lfs

未拾取 csv 文件

您似乎还没有初始化 git-lfs。尝试输入

git lfs init

来源:Installing Git LFS

简单地将 git-lfs 配置添加到现有存储库不会将您的大文件追溯转换为 LFS 支持。这些大文件将保留在您的历史记录中,GitHub 将拒绝您的推送。

您需要重写您的历史以将 git-lfs 引入您现有的提交。我推荐最近 added LFS support 的 BFG repo 清理工具。

您应该能够通过以下方式转换 CSV 文件的历史使用情况:

$ java -jar ~/bfg-1.12.5.jar --convert-to-git-lfs '*.csv' --no-blob-protection

我昨天遇到了同样的问题并破解了。我无法推送,而且 none 我的大文件似乎在 lfs 中。

可能有更好的方法,但这对我有用。我有一个包含 2.5 GB 数据的大型仓库。

我设置了一个新的存储库,然后在其中设置了 lfs。 git lfs init

然后我配置了我的各种文件类型 git lfs track "*.pdb" git lfs track "*.dll" 然后我提交了我的更改并推送。

然后我添加了我的大文件。我使用了 sourcetree,在输出注释中它会声明与我的通配符匹配的大文件,它正在提交小 txt 文件。 (抱歉,我没有记录这些,但应该很明显)。

然后我推了,看到了'skipping files',很快就推成功了。

所以问题可能是试图将文件添加到 lfs 中,这些文件已经存在于您的历史记录中。您只能添加新文件。您可能可以清理这些文件的存储库。

注意:我确实发现相当多的与我的通配符匹配的文件没有被 lfs 拾取。拾取了不同文件夹中的类似文件,但不是全部。我尝试使用完整路径显式添加这些文件。 git lfs track "Windows/bin/myBigFile.dll" 但这也无济于事。最后因为时间关系放弃了。

您还应该使用 gitHub 检查您的存储限制。我购买了额外的 50gig 来满足我的要求。

克隆存储库现在会单独下载文件,一切终于运行良好。

我有这个错误:

remote: error: File client/static/static-version/20171221_221446.psd is 223.61 MB; this exceeds GitHub's file size limit of 100.00 MB

而且因为我已经从这个文件夹中删除了这个文件,创建了 .gitignore 文件并尝试提交了几次,我不知道它被缓存了,所以我无法推送到 github。 在我的案例中帮助了:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch client/static/static-version/20171221_221446.psd'

我把完整的文件路径(来自上面的错误)从缓存中删除的地方。之后推送成功

如果您知道哪个提交引入了大型提交,您还可以尝试将该提交与引入 Git LFS 的后续提交一起压缩。

例如,如果大型提交是三个之前的提交(如 git status 所示),您可以执行以下操作:

git rebase -i HEAD~3

然后,在交互对话框中将第一个之后的所有 "pick" 用法替换为 "squash"。

然后,

git push origin --force

这可能对您有所帮助

Click-OriginalWebPage

仅将 lfs 安装到现有存储库可能还不够。 您还可以更改提交历史记录。 希望这对你有用。

我遇到了同样的问题,因为我的一些 csv 文件在之前的提交中被合并,github 拒绝了我的推送。后来我发现这个命令对我有用。

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch fixtures/11_user_answer.json'
# for my case
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch tensorflow.csv'

Original post link

我有同样的问题,但使用 filter-branch

解决了

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD

如果你有大项目,需要一些时间, 然后推

git push

从 Git LFS 2.2.0 开始,您可以使用 git lfs migrate 命令。在你的情况下,它看起来是这样的:

git lfs migrate import --include="*.csv"

在此之后,您应该能够将更改推送到源中。

有关 git lfs migrate 的更多信息,请访问 Git LFS 2.2.0 release note site and git-lfs-migrate command documentation

此解决方案适用于 Ubuntu 20.04

安装 Git 大文件存储 (git-lfs)

sudo apt-get install git-lfs
git-lfs install

要将任何预先存在的文件转换为 Git LFS,例如其他分支上的文件或您之前提交历史中的文件,请使用 git lfs migrate 命令

git lfs migrate import --include="*.ipynb" 

Select 要跟踪的文件类型

git lfs track "*.ipynb"

更新git属性

git add .gitattributes

现在推送到 git git commit -m “提交消息” git推

关于存储和带宽使用请参考

https://docs.github.com/en/github/managing-large-files/versioning-large-files/about-storage-and-bandwidth-usage

在您的终端中尝试以下命令。它将解决 lfs 问题。

git lfs migrate import --include="*.csv"