筆者我是在github上做了一個(gè)開(kāi)源庫(kù)(一個(gè)靈活配置的自定義相機(jī)庫(kù)(拍照+錄制視頻))從而錄制了一個(gè)大概200M+的gif文件,在commit完成了,push的時(shí)候 總是報(bào)錯(cuò),大致信息如下:
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不允許直接上傳大文件(超過(guò)100M)的文件到遠(yuǎn)程倉(cāng)庫(kù),若要想繼續(xù)提交可以嘗試使用大文件支持庫(kù):https://git-lfs.github.com
LFS使用的簡(jiǎn)單步驟:
-
安裝git - lfs到本機(jī)
install.png
我使用的mac,這里有三種安裝方式,按自己的習(xí)慣來(lái),我用的是Homebrew方式安裝。
- 安裝Git命令行擴(kuò)展。只需要設(shè)置一次Git LFS。
在項(xiàng)目目錄下,執(zhí)行以下命令:
git lfs install
- 選擇您希望Git LFS管理的文件類型(或直接編輯.gitattributes)。您可以隨時(shí)配置其他文件擴(kuò)展名。這一步成功后會(huì)生成一個(gè)gitattributes文件
git lfs track “* .gif” --這里的 “ *.gif "就是你要上傳的大文件的路徑
- 添加并commit gitattributes文件
git add .gitattributes
- 然后再添加大文件到本地緩存區(qū)
git add demo.gif
git commit -m "提交項(xiàng)目演示gif圖"
git push
這里要注意一點(diǎn):以上是官網(wǎng)步驟,我沒(méi)這樣走。如果你按照以上步驟走的話會(huì)還是會(huì)出現(xiàn)push fail(如下圖)的情況,可參考我的解決辦法。

image.png
參考解決辦法:
1-2步?jīng)]變,第3步我是生成.gitattributes后 add并且commit并且把.gitattributes文件push到遠(yuǎn)程分支,合并完成后,然后再add并且commit然后再push這個(gè)大文件.
