我有一个 git 存储库驻留在内存有限的服务器上。 当我尝试从服务器克隆现有存储库时,出现以下错误
hemi@ubuntu:$ git clone ssh://hemi@servername.dk/home/hemi/repos/articles
Initialized empty Git repository in /home/hemi/Skrivebord/articles/.git/
hemi@servername.dk's password:
remote: Counting objects: 666, done.
remote: warning: suboptimal pack - out of memory
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
hemi@ubuntu:$
为了处理这个错误,我尝试重新打包原始存储库(根据 this forum post )。但它没有重新打包存储库,而是描述了如何使用“git pack-objects”命令。
hemi@servername:~/repos/articles$ git repack -a -d --window-memory 10m --max-pack-size 100m
usage: git pack-objects [{ -q | --progress | --all-progress }]
[--all-progress-implied]
[--max-pack-size=N] [--local] [--incremental]
[--window=N] [--window-memory=N] [--depth=N]
[--no-reuse-delta] [--no-reuse-object] [--delta-base-offset]
[--threads=N] [--non-empty] [--revs [--unpacked | --all]*]
[--reflog] [--stdout | base-name] [--include-tag]
[--keep-unreachable | --unpack-unreachable
[<ref-list | <object-list]
服务器上安装了 Git 1.6.5.7。
最佳答案
您的解决方案已经为您提供了本地和远程的工作副本,但是当远程存储库决定再次重新打包时会再次出现问题。幸运的是,您可以设置配置选项,这将减少两个存储库中重新打包所需的内存量——这些实质上使您在重新打包时添加到默认选项中的命令行参数。所以,你应该登录到远程,切换到存储库并执行:
git config pack.windowMemory 10m
git config pack.packSizeLimit 20m
您可能想在本地存储库上执行相同的操作。 (顺便说一句,我猜想要么你的存储库非常大,要么这些机器内存很少 - 这些值对我来说似乎很低。)
值得一提的是,过去在重新打包非常 大型存储库时遇到 malloc 失败时,我还更改了 core.packedgitwindowsize
的值, core.packedgitlimit
、core.deltacachesize
、pack.deltacachesize
、pack.window
和 pack.threads
但听起来好像您不需要任何其他选项:)
关于git - 重新打包 Git 存储库失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4826639/