无法使用大文件将更改推送到 github

Not able to push changes to github with large files

嗨,我遇到了 Git 无法将提交推送到远程的问题。

我在本地有修改。

shammis-MacBook-Air:mlagents shammiseth$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch Projects/MLagents/mlagents/Project/Assets/ObstacleCourse/MamimoExport/Rifle 8-Way/‘Ch49_nonPBR.fbx'
WARNING: git-filter-branch has a glut of gotchas generating mangled history
     rewrites.  Hit Ctrl-C before proceeding to abort, then use an
     alternative filtering tool such as 'git filter-repo'
     (https://github.com/newren/git-filter-repo/) instead.  See the
     filter-branch manual page for more details; to squelch this warning,
     set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...

Rewrite 2b5367fec11dbaff653711b5bac96d5f6f39c3d3 (4/6) (1 seconds passed, remaining 0 predicted)    
WARNING: Ref 'refs/heads/master' is unchanged
shammis-MacBook-Air:mlagents shammiseth$ git push
Username for 'https://github.com':---------
Password for 'https://-----@github.com': 
Enumerating objects: 1049, done.
Counting objects: 100% (1049/1049), done.
Delta compression using up to 4 threads
Compressing objects: 100% (1023/1023), done.
Writing objects: 100% (1030/1030), 382.56 MiB | 3.16 MiB/s, done.
Total 1030 (delta 471), reused 0 (delta 0)
remote: Resolving deltas: 100% (471/471), completed with 12 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 78bb7797ed2695b18da092d0beec85d8af227589361e33ea11a21b534d6338cc
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File Project/Assets/ObstacleCourse/MamimoExport/Rifle 8-Way/Ch49_nonPBR.fbx is 111.62 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/ssshammi/mlagents.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/ssshammi/mlagents.git'
shammis-MacBook-Air:mlagents shammiseth$ 

请告诉我如何解决这个问题。

“真正的”答案可能是 git-lfs like the error message suggests, which github does have support for, but it costs money when over 2GB. If your not in a position that that is available I found this post about how to work around the 100mb file size limit,其中一些与压缩有关,可以很好地处理 .fbx 文件(因为它们是纯文本并且压缩得很好)

特别注意,您在问题中留下了一些您可能想要删除的信息(例如您的电子邮件)

这里有两个特别可疑的项目。为了发帖,我把第一行很长的一行打断了,这样就不用左右滚动了:

shammis-MacBook-Air:mlagents shammiseth$
git filter-branch --index-filter
'git rm -r --cached --ignore-unmatch
Projects/MLagents/mlagents/Project/Assets/
ObstacleCourse/MamimoExport/Rifle 8-Way/‘Ch49_nonPBR.fbx'

到此为止 git rm -r --cached --ignore-unmatched 部分还可以,但在那之后你拼出了 两个单独的文件名:

Projects/MLAgents/mlagents/Project/Assets/ObstacleCourse/MamimoExport/Rifle

作为第一个文件名,并且:

8-Way/‘Ch49_nonPBR.fbx

作为第二个文件名。因此,您的 filter-branch 命令将删除这两个文件,但是这两个文件都不存在于任何提交中。

8-Way/‘Ch49_nonPBR.fbx 中奇怪的引号可能是打字错误。在任何情况下,您肯定希望保护目录名称 Rifle 8-Way 中的 space。也就是说,您可能想要另一层引号:

'git rm -r --cached --ignore-unmatch "<insert file name here>"'

例如。仔细检查那个奇怪的 字符是否真的应该也在那里。

第二个可疑物品是:

WARNING: Ref 'refs/heads/master' is unchanged

这告诉我们您的 git rm -r --cached --ignore-unmatched 命令没有效果。没有提交需要任何更改,因此没有构建新的和改进的替换提交,因此最后,refs/heads/master 指的是您最初拥有的相同最终提交。

您最好使用其他工具来修复您的提交。