今天往GitHub提交代码时候出现了报错,错误信息以及解决办法如下
报错信息如下
➜ webgl_3d_development_action git:(main) git push -u origin main
Enumerating objects: 1465, done.
Counting objects: 100% (1465/1465), done.
Delta compression using up to 16 threads
Compressing objects: 100% (1401/1401), done.
Writing objects: 100% (1465/1465), 131.97 MiB | 574.00 KiB/s, done.
Total 1465 (delta 424), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (424/424), done.
remote: error: Trace: cccde3a3996c57ba0d90a204dfefb0cc5ad95d91376d5b139e1c96027b100c53
remote: error: See https://gh.io/lfs for more information.
remote: error: File 第12章 Three.js引擎进阶/Sample12_9/obj/object.obj is 194.01 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:tangpostkarte/webgl_3d_development_action.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'github.com:tangpostkarte/webgl_3d_development_action.git'
上面的这个的错误是说我们的文件大小超过了100MB了,需要我们使用 Git Large File Storage这个插件才可以。那么我们按照上面的方法安装这个插件。具体操作如下。
错误解决
下载插件
wget https://github.com/git-lfs/git-lfs/releases/download/v3.6.1/git-lfs-linux-amd64-v3.6.1.tar.gz
解压
tar -xf git-lfs-linux-amd64-v3.6.1.tar.gz
进入解压好的目录安装
# 进入目录
cd git-lfs-3.6.1
# 安装
sudo ./install.sh
跟踪大文件
查看排序项目中比较大的文件有哪些
find ./ -type f -exec du -h {} + | sort -h
将比较大的文件加入到Git LFS的管理中
git lfs track "*.obj"
执行完上面的命令后,我们可以看到项目目录下多了一个.gitattributes文件, 该文件即为我们让Git LFS追踪管理的文件。
上面操作完成后,即可正常推送到远程GitHub仓库了。