通常我們commit完成之后扁凛,往Github上push的時(shí)候盾沫,單個(gè)文件大小不會(huì)超過100M裁赠,所以基本不會(huì)遇到這種情況。
但是赴精,總會(huì)遇到的佩捞,當(dāng)單個(gè)文件超過100M的時(shí)候,push的時(shí)候會(huì)出現(xiàn)下面這樣的Error:
remote: Resolving deltas: 100% (472/472), done.
remote: error: GH001: Large files detected.
You may want to try Git Large File Storage - https://git-lfs.github.com.
或者:
Total 3007 (delta 664), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: Trace: 7b7de6b9372ee392e0f3961b05ea6f33
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File XXX/XXX/XXX is 234 MB; this exceeds GitHub‘s file size limit of 100.00 MB
remote: error: File XXX/XXX/XXX is 234 MB; this exceeds GitHub‘s file size limit of 100.00 MB蕾哟。
上面錯(cuò)誤的原因很好理解就是GitHub不允許直接上傳大文件(超過100M)的文件到遠(yuǎn)程倉庫一忱,若要想繼續(xù)提交可以嘗試使用大文件支持庫:https://git-lfs.github.com
LFS使用的簡單步驟:
- 安裝git - lfs到本機(jī)
這里沒有什么難度莲蜘,根據(jù)官網(wǎng)安裝就好。
之后就是提交大文件的順序帘营,下面是官網(wǎng)的順序:
- 安裝Git命令行擴(kuò)展票渠。只需要設(shè)置一次Git LFS。
在項(xiàng)目目錄下芬迄,執(zhí)行以下命令:
git lfs install
- 選擇您希望Git LFS管理的文件類型(或直接編輯.gitattributes)问顷。您可以隨時(shí)配置其他文件擴(kuò)展名。這一步成功后會(huì)生成一個(gè)gitattributes文件
git lfs track “* .a” --這里的 “ *.a "就是你要上傳的大文件的路徑
- 添加并commit gitattributes文件
git add .gitattributes
- 然后再添加大文件到本地緩存區(qū)
git add demo.a
git commit -m "提交.a大文件"
git push
以上禀梳,按照上述的方法杜窄,第一次上傳大文件基本還是會(huì)報(bào)錯(cuò),而且百思不得其解~
尼瑪出皇,新手入坑總是這個(gè)尿性羞芍。哗戈。
如下圖:
出現(xiàn)上述問題郊艘,先reset 到你剛才commit的前一個(gè)commit,(意思就是撤銷剛才的commit,回到起點(diǎn)再來一次唯咬。)
第一纱注、二步同上,第三步的時(shí)候胆胰,先將 .gitattributes文件狞贱,單獨(dú)commit,然后push蜀涨,完成之后瞎嬉,在進(jìn)行第四部(第四部add 之后 執(zhí)行git lfs ls-files
應(yīng)該能看見東西了)。
到這里應(yīng)該就沒問題了厚柳。
喜歡我的可以關(guān)注收藏我的個(gè)人博客:Ro.bber