您可能正在推送多个提交,其中一个包含一个大文件,另一个包含较新的文件removing那个文件。
2020-2022:
Use git filter-repo https://github.com/newren/git-filter-repo(基于python,将首先安装 https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
并使用一些基于内容的过滤 https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#_content_based_filtering:
如果你想过滤掉所有大于特定大小的文件,你可以使用--strip-blobs-bigger-than
具有一定的尺寸(K
, M
, and G
后缀被识别),例如:
git filter-repo --strip-blobs-bigger-than 10M
原始答案,使用过时的工具,例如git filter-branch or BFG https://stackoverflow.com/a/58251653/6309:
无论如何,您都可以尝试,如“修复“这超出了 GitHub 100 MB 的文件大小限制”错误 http://www.thisprogrammingthing.com/2013/fixing-the-this-exceeds-githubs-file-size-limit-of-100-mb-error/“,一个过滤器分支(如果您知道看不到的大文件的名称/路径)
git filter-branch --index-filter 'git rm --cached --ignore-unmatch e3384023be667de7529538b11c12ec68.201307290946.sql.gz' <sha1>..HEAD
或者,如果你不知道但想摆脱any大文件(例如 > 90MB),您可以使用BFG 回购清理器 http://rtyley.github.io/bfg-repo-cleaner/
bfg --strip-blobs-bigger-than 90M my-repo.git
这将在您的存储库历史记录中跟踪您难以捉摸的大文件并将其删除。
请注意,您必须执行git push --force
之后,因为最近提交的历史记录将被修改。
如果其他人之前已经克隆了您的存储库,则需要进行一些沟通以警告他们。