用lfs上傳大檔案到github
阿新 • • 發佈:2022-05-10
簡要
- 有時候需要將大檔案(超過100M)上傳到Github上,這時候就需要用到```lfs``,但是其使用有限制的:儲存限制大致意思是一個月累計只能上傳不超過1GB的檔案,頻寬一個月累計只能下載不超過1GBGithub說明文件
- 參考的教程
步驟 & 值得留意的步驟
- 我首先將除大檔案外都上傳到 Github 上(此時大檔案沒有
git add
,並不在Git本地倉庫中) - 確保已經安裝了 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
- 此時提示完成應該就成功上傳了,並且在Github倉庫上也可以看到
上傳成功但是在倉庫沒有找到這個檔案
上傳完成後,在Github->Setting->Billing中的Git LFS Data 中看到有檔案了卻在倉庫找不到(忽略儲存未使用)而且commit也沒有,很可能是在使用git lfs track
追蹤檔案時沒有新增引號,一定要加引號。
然後重新新增引號後發現之前的commit
也顯示出來了
報如圖錯誤
把綠色框中複製貼上再重新```push````就可以了,