一、将大于100M大文件不入库
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch xxxx/xxxx.xx'
二、使用 git-lfs(Git Large File Storage) 支持单个文件超过100M
1.安装Git命令行扩展。只需要设置一次Git LFS。
//在项目目录下,执行以下命令:
git lfs install
2.选择您希望Git LFS管理的文件类型。这一步成功后会生成一个gitattributes文件
git lfs track "*.a" //这里的 “ *.a "就是你要上传的大文件的路径
3.添加并commit/push gitattributes文件
git add .gitattributes
git push
4.然后再添加大文件到本地缓存区
git add framexxxxx.a
git lfs ls-files //追踪指定类型的文件
git commit -m ""
git push
总结一些报错
1.Remote “origin” does not support the LFS locking API. Consider disabling it with
git push -u origin develop1.0
Remote "origin" does not support the LFS locking API. Consider disabling it with:
$ git config lfs.https://git.oschina.net/XXX/xxx.git/info/lfs.locksverify false
Git LFS: (0 of 1 files) 0 B /125.55 MB
batch request: Access denied
exec request failed on channel 0: exit status 255
error: failed to push some refs to 'git@git.oschina.net:XXX/xxx.git'
解决方式:
git config lfs.https://git.oschina.net/XXX/xxx.git/info/lfs.locksverify false
2、batch request: Access denied
git push -u origin develop1.0
Remote "origin" does not support the LFS locking API. Consider disabling it with:
$ git config lfs.https://git.oschina.net/XXX/xxx.git/info/lfs.locksverify false
Git LFS: (0 of 1 files) 0 B / 125.55 MB
batch request: Access denied
exec request failed on channel 0: exit status 255
error: failed to push some refs to 'git@git.oschina.net:XXX/xxx.git'
解决方式:
# 删除 .git/hooks/pre-push 文件即可
That looks like a server issue with deploy keys. For now, try removing .git/hooks/pre-push.
3、GitHub 目前 Git LFS的总存储量为1G左右,超过需要付费。(上传失败时,可以开启VPN进行上传)
4、batch response: Repository or object not found
$ git lfs push origin master
Git LFS: (0 of 1 files) 0 B /125.55 MB
batch response: Repository or object not found: https://gitee.com/XXX/xxx.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it
失败原因:
是gitee.com这个git仓库并不支持lfs,所以在大文件入库的时候,提示失败
文章参考:https://blog.csdn.net/u012390519/article/details/79441706 https://blog.csdn.net/qq_43827595/article/details/105673569
网友评论