Git Error: pack-objects died, out of memory

紀錄一下…

今天遇到的,不過其實該 repository 也沒有很大的檔案,但是在 clone 的時候就會在 Compresing objects 的時候掛掉,然後回來這樣的錯誤訊息。

$ git clone git@SERVER:NS/PROJECT.git Cloning into 'PROJECT'...
remote: Counting objects: 3081, done.
remote: warning: suboptimal pack - out of memory
error: pack-objects died of signal 95/1154)   
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

解決方法是從 server 上強制太大的檔案不要 compress,直接在 clone 的時候做下載。

/var/opt/gitlab/git-data/repositories/NS/PROJECT.git$ more config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = true
[remote "origin"]
	url = /var/opt/gitlab/backups/repositories/NS/PROJECT.bundle
	fetch = +refs/*:refs/*
	mirror = true

/var/opt/gitlab/git-data/repositories/NS/PROJECT.git$ git config pack.windowMemory 10m
/var/opt/gitlab/git-data/repositories/NS/PROJECT.git$ git config pack.packSizeLimit 20m

/var/opt/gitlab/git-data/repositories/NS/PROJECT.git$ more config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = true
[remote "origin"]
	url = /var/opt/gitlab/backups/repositories/NS/PROJECT.bundle
	fetch = +refs/*:refs/*
	mirror = true
[pack]
	windowMemory = 10m
	packSizeLimit = 20m