今天用指令git push origin main向github进行文件上传的时候,忽然报错,错误如下所示,我们可以看到是因为我们上传的文件太大了,超出了github的100M文件限制。所以接下来我们就探讨一下如何解决这个问题。
remote: Resolving deltas: 100% (2/2), completed with 1 local object. remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com. remote: error: Trace: 44a3c2eab8bd7ed1961ba1620af4c7abde54114261375ae73e6bbf53e3fd029e remote: error: See http://git.io/iEPt8g for more information. remote: error: File order_data/MNIST/x_train_order.npy is 328.98 MB; this exceeds GitHub's file size limit of 100.00 MB To github.com:zhou-zenghui/MRCoverage.git本次配置的环境是建立在
软件版本电脑系统Windows10Git版本2.29.0Git-lfsWindows10时间2020年10月22日GitHub不允许直接上传大文件(超过100M)的文件到远程仓库,若要想继续提交可以尝试使用大文件支持库Git-lfs的支持,Git LFS 通过将仓库中的大文件替换为微小的指针(pointer) 文件来做到这一点。在正常使用期间,你将永远不会看到这些指针文件,因为它们是由 Git LFS 自动处理的。
默认电脑已经安装好Git并且已经配置好远程仓库,那么接下来我们需要去git-lfs官网去下载安装包并及进行安装。 打开git-bash,在项目目录下,执行以下命令:
git lfs install然后添加选择您希望Git LFS管理的文件类型,这一步成功后会生成一个gitattributes文件,之后也可以选择在这个文件内部直接进行编辑。
git lfs track "*.大文件的扩展名"然后添加.gitattributes文件并commit,之后单独push这个文件到到远程端,如果之前已经添加过大型文件,可以撤销或者回退。
git add .gitattributes git commit -m "add the .gitattributes" git push origin main再然后就可以放心的push文件啦!
