Git 在分支中找不到文件但不会提交,因为文件太大

Git can not find files in branch but will not commit because a file is too large

问题:我有一个 git 分支,我正试图将其推送到远程。推送失败并显示以下消息:

Writing objects: 100% (881/881), 31.27 MiB | 821.00 KiB/s, done.
Total 881 (delta 691), reused 0 (delta 0)
remote: warning: File one.pickle is 79.43 MB; this is larger than
GitHub's recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected.
remote: error: Trace: 2056a7d69782753a64379d283d737b94
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File two.pickle is 173.14 MB; this exceeds
GitHub's file size limit of 100.00 MB
To https://github.com/blah/blahblah.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to     
'https://github.com/blah/blahblah.git'

所以我的自然反应是完全从分支历史记录中删除文件。问题是 git 找不到文件。它们无处不在,但在出错时出现在提交上。

我也试过了

git rm --cached one.pickle

我也试过 filter-branch

git filter-branch -f --tree-filter 'rm one.pickle' HEAD

但收到以下..

Rewrite 554f5c56e41049394b3714dba1b409f30ca76f8 (1/391)rm:
one.pickle: No such file or directory
tree filter failed: rm one.pickle

问题:当我认为 one.pickle 和 two.pickle 不存在时,如何让我提交到远程推送?

对于git filter-branch,您需要使用不会失败的命令。

在这种情况下,它会在尚未添加文件的提交上失败。 更改命令以忽略丢失的文件:

git filter-branch -f --tree-filter 'rm -f one.pickle' HEAD