git out of memory errors – git repack

git out of memory errors – git repack

Occasionally when using git (particularly with large repositories) you might come across an error that looks a little bit like this:

[codesyntax lang=”bash” lines=”no” container=”none” blockstate=”expanded”]

remote: Counting objects: 506, done.
remote: fatal: Out of memory, malloc failed (tried to allocate 342222798 bytes)
remote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

[/codesyntax]

It means the remote server has run out of memory while packing objects on the server ready to send down the wire, and has aborted the pull request mid-way.  If you know you’ve got some particularly massive files in your repository that you didn’t really need there, you could rewrite history and get rid of them, but chances are you just need to do a little maintenance on your remote repository.

Connect to your remote server, and find the repo in question, then just run the following:

[codesyntax lang=”bash”  container=”none”]git repack -a -f -d[/codesyntax]

Now you should be able to pull your repo again, with everything already packed on the server.

Obviously, you can find more about those options with:

[codesyntax lang=”bash” lines=”no” container=”none”]

man git-repack

[/codesyntax]

Tags: , , ,

Leave a Reply?