【问题标题】:Github - File XYZ is 126.80 MB; this exceeds GitHub's file size limit of 100.00 MBGithub - 文件 XYZ 为 126.80 MB;这超出了 GitHub 的文件大小限制 100.00 MB
【发布时间】:2015-09-29 17:14:59
【问题描述】:

我有一个本地存储库,意外添加了一个大文件。现在我几乎落后了 100 个提交。当我尝试推送到 GitHub 时,它给了我一个错误。

我需要帮助来完成我需要做的任何事情才能推送此存储库的其余部分。

我不需要这个文件,可以永久删除它

(旁注:这是一个包含 IPython 节点和代码的目录。我有一个脚本自动推送它,这就是为什么我落后了将近 100 次提交。我只是注意到它没有同步)

这是我尝试过但没有成功的方法:

git status

在分支主 您的分支领先于“origin/master”100 次提交。
(使用“git push”发布您的本地提交)
没有什么可提交的,工作目录干净

git filter-branch --index-filter 'git rm --cached --ignore-unmatch "Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt"' --tag-name-filter cat -- --all

重写 d381c7d5037a6a26abb2b5cef06e57d8b86a398b (95/189)rm '教育/Coursera/探索性数据分析/Week1/household_power_consumption.txt'
..
重写 f639b57714a5d57ff37b9d4a55c1c69fc0b514a8 (176/189)rm '教育/Coursera/探索性数据分析/Week1/household_power_consumption.txt'
重写 587c8b65f19315ebeb6627a75bd703a5dbdec208 (189/189)

Ref 'refs/heads/master' 被重写
警告:参考 'refs/remotes/origin/master' 未更改

git rm "Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt"

致命:pathspec 'Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt' 与任何文件都不匹配

git push

警告:push.default 未设置;它的隐含价值在 Git 2.0 中从“匹配”变为“简单”。要在默认更改后消除此消息并保持当前行为,请使用:

git config --global push.default matching

要压制此消息并立即采用新行为,请使用:

git config --global push.default simple

当 push.default 设置为 'matching' 时,git 会将本地分支推送到已经存在的同名远程分支。

在 Git 2.0 中,Git 将默认采用更保守的“简单”行为,仅将当前分支推送到“git pull”用来更新当前分支的相应远程分支。

请参阅“git help config”并搜索“push.default”以获取更多信息。
('simple' 模式是在 Git 1.7.11 中引入的。如果您有时使用旧版本的 Git,请使用类似的模式 'current' 而不是 'simple')

计数对象:841,完成。
Delta 压缩最多使用 2 个线程。
压缩对象:100% (578/578),完成。
写入对象:100% (835/835),31.79 MiB | 3.14 MiB/s,完成。
总计 835(增量 196),重复使用 0(增量 0)

远程:警告:文件 .git-rewrite/t/Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt 为 74.92 MB;这大于 GitHub 建议的最大文件大小 50.00 MB
远程:警告:文件 .git-rewrite/t/Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt 为 69.38 MB;这大于 GitHub 建议的最大文件大小 50.00 MB

远程:错误:GH001:检测到大文件。
远程:错误:跟踪:f013f5e75b4f35d07de5d2d9ef1116bd
远程:错误:有关详细信息,请参阅 http://git.io/iEPt8g
远程:错误:文件 .git-rewrite/t/Education/Coursera/Exploratory Data Analysis/Week1/household_power_consumption.txt 为 126.80 MB;这超出了 GitHub 的文件大小限制 100.00 MB

到 git@github.com:rbohac/IPython-Notebooks.git ! [remote denied] master -> master (pre-receive hook denied)
错误:无法将一些参考推送到 'git@github.com:rbohac/IPython-Notebooks.git'

【问题讨论】:

标签: github


【解决方案1】:

确保您的最新提交是正确的,因为 BFG 将假定这一点并使用您的最新提交来维护您的存储库的状态,同时它会重写和清理 Git 历史记录。 BFG 类似于“git-filter-branch”,但它是为更具体的目的而编写的实用程序,而 git 实用程序更广泛,具有更多功能,但牺牲了运行效率。当我从该来源获得所有这些信息时,请阅读有关 BFG 的文档以获取更多详细信息。

brew install bfg
bfg --strip-blobs-bigger-than 50M
git rm --cached XYZ
git commit --amend -CHEAD
git push

BFG 会更新你的提交和所有的分支和标签,所以它们是干净的,但它不会物理删除任何东西。检查 repo 以确保一切正确,然后清除缓存并运行“git gc”以删除 Git 现在可以识别的不需要的数据,因为它已从历史记录中删除。

进一步:

【讨论】:

  • 试过 bfg ubuntu@ip:~$ java -jar bfg-1.12.3.jar --strip-blobs-bigger-than 50M --no-blob-protection IPythonNotebooks/.git Using repo : /home/ubuntu/IPythonNotebooks/.git Scanning packfile for large blobs completed in 8 ms. Warning : no large blobs matching criteria found in packfiles - does the repo need to be packed? Please specify tasks for The BFG : bfg 1.12.3
  • Nathan 我详细说明了我的答案,但我只是从 bfg 的文档中得到了这一切。阅读他们的文档了解更多详情。
【解决方案2】:

在使用 brew install bfg 安装后,我在使用 bfg 时遇到了问题,尽管我通常使用自制软件非常成功。

这对我有用:

  • https://rtyley.github.io/bfg-repo-cleaner/#download下载最新bfg

  • 像这样执行 bfg,然后输入@davidcondrey 推荐的其余命令

    cd /my/repo
    java -jar ~/Downloads/bfg-1.12.5.jar --strip-blobs-bigger-than 99M
    git rm --cached XYZ
    git commit --amend -CHEAD
    git push 
    

【讨论】:

  • 这对我有用: git rm --cached XYZ git commit --amend -CHEAD git push origin master
  • @Justin Schier 你能解释一下原因和为什么会这样吗?
【解决方案3】:

不使用bfg的另一种解决方案,我使用了这个脚本remove-big-file.sh 由布鲁诺格兰德开发。

执行前请阅读脚本,理解每一步

简要说明:它考虑了一个本地变基,编辑包含大文件的提交(不是从 git 物理上删除它)和amend 提交并最终推送(这将包括您尝试后完成的任何其他提交修复它)。

我遇到了同样的问题,我的方法如下:我从 git 中删除了文件,还更新了我的 .gitignore 并提交了这些更改,但仍然面临同样的错误。 (手动)执行脚本的每个步骤后,它都已解决,请注意推送将包括您在本地完成的所有提交。

【讨论】:

    猜你喜欢
    • 2016-01-24
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    • 2020-02-26
    • 2021-01-24
    • 1970-01-01
    • 2018-01-02
    • 1970-01-01
    相关资源
    最近更新 更多