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://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:$
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.
With no direct access to repository and hence being unable to perform a repack, performing a shallow clone and then gradually fetching while increasing depth helped for me.
Hope it can still help someone.
I solved the problem using the following steps.
git repack -a -d --window-memory 10m --max-pack-size 20m
git init --bare
This does not answer the question, but somebody might run into it: repacking might also fail on the server when
pack-objects
is terminated by some kind of memory killer (such as the one used on Dreamhost):On Dreamhost this appears to be caused by
mmap
. The repack code usesmmap
to map some files’ contents into memory, and as the memory killer is not smart enough, it counts the mmapped files as used memory, killing the Git process when it tries tommap
a large file.The solution is to compile a custom Git binary with
mmap
support turned off (configure NO_MMAP=1
).I had the same problem on ubuntu 14.10 with git 2.1.0 on a private github.com repository. (Entreprise router is suspected! Works on different wifi network, except at workplace)
My solution was, to git clone using ssh (I set up ssh keys* beforehand), like this:
becomes:
*: (Generating an ssh key)
Then log into github, in settings, import ssh keys, and import it from ~/.ssh/id_rsa.pub.
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:
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
andpack.threads
but it sounds as if you don't need any further options :)I am using git version 1.7.0.4 and it accepts this command. It is possible that git version 1.6 doesn't accept this command.
Try creating a new repository with some random commits. Then repack it with this command.