快轉到主要內容

Github 檔案太大無法推送!?安裝「Git-LFS」馬上解決!

·875 字
Computer-Science Github
目錄

使用 git push 推送檔案到 Github 上時,被告知檔案太大無法推送!?馬上教你怎麼解決!


報錯
#

當你嘗試使用 git push 推送超過100 MB的檔案時,沒意外就會收到這樣的錯誤。
這是因為 Github 一個檔案最大上傳限制就是100 MB。(ps. 分開上傳可以,但不能同個檔案 100 MB)

1$ remote: error: GH001: Large files detected.
2$ remote: error: Trace: xxxxxxxxxxxxxxxxxxxx
3$ remote: error: See http://git.io/iEPt8g for more information.
4$ remote: error: File xxxxxxxxxxxxx is 101.00 MB; this exceeds GitHub's file size limit of 100 MB

安裝 Git-LFS 解決!
#

為此 Github 也提供解決方法 - 「Large File Storage」。

Debian and Ubuntu
#

1curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
2sudo apt-get install git-lfs
3git lfs install

Mac OSX
#

1brew update
2brew install git-lfs
3git lfs install

RHEL/CentOS
#

Step.1 安裝 git >= 1.8.2
#

如果你的版本是 RHEL/CentOS 57 (而不是 6)的話:
a. 可以按這裡安裝 (如果是 CentOS 那麼你只需要執行 sudo yum install epel-release)
b. sudo yum install git

如果你的版本是 RHEL/CentOS 6
a. curl -s https://setup.ius.io/ | sudo bash
b. sudo yum install git2u

如果你想,你也可以自己建構原始碼。您將需要手動下載 Git-lfs rpm 並進行安裝 rpm -i --nodeps git-lfs*.rpm

Step.2 安裝 git-lfs
#

1curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
2sudo yum install git-lfs
3git lfs install

Windows
#

Step.1 下載安裝檔
#

可以從 https://github.com/git-lfs/git-lfs/releases 選擇你要的版本進行下載。

Step.2 執行安裝檔
#

Step.3 在 CMD 或者 Git-Bash 執行 git lfs install
#


開始使用
#

在下 git 指令時,你只需要將追蹤大檔案(超過 100 MB)的指令 git add 改成 git lfs track
舉例來說,如果要追蹤副檔名為.psd的大檔案,那請使用

1git lfs track "*.psd"

不是 git add "*.psd"
並且確保檔案 .gitattributes 有被追蹤。 (這是用來告知 github 此為大型檔案的文件)

1git add .gitattributes

之後的指令照舊, git add > git commit > git push
回到 Github Repository 就可以發現成功被推送了。


如何取消 LFS ?
#

  • 刪除單個檔案
    如果你是要刪除單個檔案,那麼就需要麻煩點到「.gitattributes」這個檔案中去刪除單筆資料,使 Github 知道該檔案不用再被 LFS 給追蹤。
  • 移除全部 (不使用 LFS 了)
    你需要使用指令「git lfs uninstall」,如果你是較舊的版本則是使用指令「git lfs uninit」來刪除該 Repository 中的 LFS 。
    另外也請確保檔案「.gitattributes」不再被追蹤。(建議如果不需要,請直接下 git rm .gitattributes 刪除它)

範例:

1git lfs uninstall
2git rm .gitattributes
3git add .
4git commit "Uninstall LFS"
5git push origin main

參考資料
#

Alpaca
作者
Alpaca
No one can stop my feet.

相關文章

進階 Google 搜尋技巧 - Google Hacking
·1706 字
Computer-Science Google

這個被稱作「Google Hacking」的技巧,不僅可以快速找到你要的資料,甚至常被拿來… 肉搜

非對稱加密 (Asymmetric Cryptography)
·1223 字
Computer-Science Cryptography Digital Signature

這次提到的概念是比上次的「 Symmetric Cryptography 」來的更進階的「 Asymmetric Cryptography (非對稱加密) 」,其概念被廣泛運用在數位簽章

對稱加密 (Symmetric Cryptography)
·1399 字
Computer-Science Cryptography

大家對於「密碼」並不陌生,生活中總是遇到許多場合需要用到密碼,然而「加密」的原理似乎相對的卻不是那麼的備受關注。

Social-Engineering 社交工程|你駭計算機,我駭你心。
·2000 字
Computer-Science Social-Engineering Psychology Phishing

什麼是社交工程?是心理學的一種嗎?兩者之間有什麼關聯?社交工程是指詐騙嗎?

嘿!別想的太複雜,其實你應該也經歷過

網頁漏洞 XSS (Cross-Site-Scripting) 攻擊 (下) 進階思路解說
·1873 字
Computer-Science XSS
上一篇提到了基礎的 XSS 原理,這次要來介紹更深入更進階的思路了。
網頁漏洞 XSS (Cross-Site-Scripting) 攻擊 (上) 基礎原理解說
·2194 字
Computer-Science XSS
常常聽到有人說網站出現「XSS 漏洞」,那這所謂的 XSS 到底是什麼?其可怕之處又為何?以下,帶你淺談 XSS (跨站運行腳本) 原理。