用lfs上传大文件到github

简要

步骤 & 值得留意的步骤

  1. 我首先将除大文件外都上传到 Github 上(此时大文件没有git add,并不在Git本地仓库中)
  2. 确保已经安装了 lfs, 我的大文件叫LeavesDiseaseClassification220327.pth,大小是256M
git lfs install

git lfs track model_data/LeavesDiseaseClassification220327.pth

git add .gitattributes

git add model_data/LeavesDiseaseClassification220327.pth

git commit -m "add Lea.pth"

git push github master 
  • 有注释版本
git lfs install # 执行下没啥坏处

git lfs track "LeavesDiseaseClassification220327.pth" # 一定要加引号 一定要加引号 一定要加引号

git add .gitattributes

git add LeavesDiseaseClassification220327.pth # 这里不需加

git commit -m "add Lea.pth" 

git push github master 
  1. 此时提示完成应该就成功上传了,并且在Github仓库上也可以看到

上传成功但是在仓库没有找到这个文件

上传完成后,在Github->Setting->Billing中的Git LFS Data 中看到有文件了却在仓库找不到(忽略存储未使用)而且commit也没有,很可能是在使用git lfs track追踪文件时没有添加引号,一定要加引号

  • 没有添加引号的错误示例
git lfs track LeavesDiseaseClassification220327.pth # 没有加引号!!!


然后重新添加引号后发现之前的commit也显示出来了

报如图错误


把绿色框中复制粘贴再重新```push````就可以了,

posted on 2022-05-10 17:45  stuMartin  阅读(667)  评论(0编辑  收藏  举报

导航