git - 重新打包 Git 存储库失败

标签 git repository

我有一个 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.packedgitlimitcore.deltacachesizepack.deltacachesizepack.windowpack.threads 但听起来好像您不需要任何其他选项:)

关于git - 重新打包 Git 存储库失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4826639/

相关文章:

java - 使用 Maven 将版本文件放入 EAR 或 WAR

由于 merge 错误,Git 分支处于不一致状态

windows - 是否有人使用 libgit2、libgit2sharp、Ngit 来替代 msysgit 的 Windows?

macos - Git 命令在 OSX 上需要 sudo

perl - 将 "file name"从文本文件传递到命令行,其中文件的每一行都是文件名

java - 当 pageable.size = 1 时,具有可分页、连接表的 JPA 存储库 nativeQuery 不起作用

c# - 依赖注入(inject)的实现

php - Laravel 5 SQLSTATE[42S02] : Base table or view not found

git checkout 删除网站上传

android - 使用 kotlin co 例程从单个函数返回多次