Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repack of Git repository fails

Tags:

git

repository

I have a git repository residing on a server with limited memory. When I try to clone an existing repository from the server I get the following error

hemi@ubuntu:$ git clone ssh://[email protected]/home/hemi/repos/articles Initialized empty Git repository in /home/hemi/Skrivebord/articles/.git/ [email protected]'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:$  

To handle this error I have tried to repack the original repository (according to this forum post). But instead of repacking the repository it describes how to use the "git pack-objects" command.

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 is installed on the server.

like image 314
midtiby Avatar asked Jan 28 '11 09:01

midtiby


People also ask

What is repacking Git?

DESCRIPTION. This command is used to combine all objects that do not currently reside in a "pack", into a pack. It can also be used to re-organize existing packs into a single, more efficient pack.

How do I reduce the size of a .pack file in Git?

When you do a Git clone, it will create a copy of the whole repository, this includes the pack file as this is part of the repo too. The only way to reduce the size of the pack file will be by removing contents from your repo.


1 Answers

Your solution has got you a working copy locally and remotely, but will cause problems again when the remote repository decides to repack itself again. Fortunately, you can set config options that will reduce the amount of memory needed for repacking in both repositories -- these essentially make the command line parameters that you added into the default options when repacking. So, you should log in to the remote, change into the repository and do:

git config pack.windowMemory 10m git config pack.packSizeLimit 20m 

You may want to do the same on your local repository. (Incidentally I guess that either your repository is very large or these are machines with little memory - these values seem very low to me.)

For what it's worth, when getting malloc failures on repacking very large repositories in the past, I've also changed the values of core.packedgitwindowsize, core.packedgitlimit, core.deltacachesize, pack.deltacachesize, pack.window and pack.threads but it sounds as if you don't need any further options :)

like image 187
Mark Longair Avatar answered Sep 20 '22 14:09

Mark Longair