git上传大文件

remote: error: GH001: Large files detected.
remote: error: Trace: 7b7de6b9372ee392e0f3961b05ea6f33
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File *.framework/Versions/A/* is 207.25 MB; this exceeds GitHub's file size limit of 100.00 MB      

在使用Git时,你是否遇到过这种问题?遇到这种问题后又该如何操作呢?
目前有两种方法:

1. 删除大于100M的文件,不上传大文件

1-1. 删除磁盘缓存
git rm --cachedgit rm -r --cached
1-2. 将大文件从commit记录中移除且以后commit都将不会再将其commit
git commit --amend -CHEAD
1-3. 推送至远程服务器
git push origin master(第一次推送时命令)或git push

2. 突破大文件上传限制,使用git-lfs(Git Large File Storage)原地址

git上传大文件
2-1. 安装,我是用的是Macbook Pro,所以选择macOS用户安装方式 Homebrew 安装
brew install git-lfs
2-2. 打开终端,cd到git仓库路径,初始化lfs
git lfs install
2-3. 追踪单个文件
git lfs track
eg:git lfs track "*.psd"
2-4. 添加lfs追踪文件,提交仓库(此处一定要先提交追踪文件到仓库,在提交其他文件)
git add .gitattributes
git commit -m "track *.psd files using Git LFS"
git add .
git commit -m "submit other files"
2-5. 验证是否追踪大文件,如果输入后不显示则追踪不成功
git lfs ls-files
2-6. 推送至远程仓库
git push origin master

Uploading LFS objects: 100% (1/1), 810 B, 1.2 KB/s
# ...
To https://github.com/git-lfs/git-lfs-test
   67fcf6a..47b2002  master -> master

目前OSChina仅支持付费企业支持,个人需通过邮件 [email protected] 联系支持
(fls说明),GitLab需在项目设置中手动开启此功能,本项目我是以GitHub私人项目实验。

注意:

Q1:上传成功后,拉取工程报错,有的文件中出现如下信息
version https://git-lfs.github.com/spec/v1 
oid sha256:446a6063f3b698c388700d
size 1127229450
Q1 解决方案:

造成此问题的原因是可能是framework文件追踪不成功导致的(我是因为这个导致的)可看Q2如何追踪framework文件。删除GitHub仓库,按照lfs方法的流程重新来一遍即可。

Q2:framework超过100M的文件如何上传?然而lfs的作者并没有给出答案,只是让去看文档!
提示错误如下
emote: error: 
File *.framework/Versions/A/* is 207.25 MB; 
this exceeds GitHub's file size limit of 100.00 MB        
Q2 解决方案:

按照错误提示追踪framework库,因为macOS系统会将其看成一个文件夹
git lfs track "*.framework/Versions/A/*"
注意提交追踪文件后验证一下
git lfs ls-files

Q2问题参考