1. 程式人生 > 其它 >用lfs上傳大檔案到github

用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追蹤檔案時沒有新增引號,一定要加引號

然後重新新增引號後發現之前的commit也顯示出來了

報如圖錯誤


把綠色框中複製貼上再重新```push````就可以了,