Git Server 噴 git upload-pack: git-pack-objects died with error

Git-Logo-2Color

透過 Gitlab 架設 Git Server 來放一些 Document 資料,由於個人 Document 都是 pdf 檔案,所以整個 Git Repository 就非常肥大,今天在 Clone 下來的時候,不僅是主機 CPU 飆高,然後記憶體被吃到快沒了,最後還噴出底下錯誤訊息

remote: Counting objects: 4912, done.
remote: fatal: Out of memory, malloc failed
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

網路上查到這篇

Git clone error + remote: fatal: Out of memory, malloc failed + error: git upload-pack: git-pack-objects died with error. 解法,裡面提到在每次 clone 專案時,Git 都會將資料壓縮並且存放到記憶體,所以如果 Repository 超過 100MB,你就會發現記憶體漸漸減少,然後整個炸掉,解法就是設定此 Repository 讓大家直接下載檔案,不要先丟到記憶體內,所以請打開 config 設定檔案,裡面寫入

[pack]
    window = 0

See also