I can't clean up a git repo. If I try to, I get this error message:

$ git gc
Counting objects: 8828, done.
fatal: Cannot handle files this big
error: failed to run repack

If I google it, there are literally only 2 results: This question and the error message as a pastebin entry which was submitted 2 minutes after I first posted this question here. So no one else seems to have the problem.

Granted, there is a 4.8 GB file tracked with git and git takes about 8 to 9 GiB of virtual ram on my laptop when running git gc, and my raspi only has 1 GB of physical ram. However, it usually has a 1 GiB swap and I just added a 30 GiB swap to do this operation. So it should have enough ram.

Unfortunately, the error message doesn't contain the reason why the cleanup command can't handle files that big. So I don't know what the limiting property of my system is.

What is the problem and is it possible to do the cleanup on the raspberry pi? (Transferring it to a desktop computer doesn't seem like a good solution to me.)

I actually planned on cleaning up some way bigger repos using my raspi because it runs anyways and this way I might not need to have my computer run for hours.

I thought that maybe cloning the repo will yield a cleaned-up repo. However, I get this output:

$ git clone ../Documents
Cloning into 'Documents'...
fatal: Cannot handle files this big   
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

However, adding --bare to the clone command returns instantly with no error. (Probably some ext4 magic going on so the files are copied on-write.) Needless to say, no cleaning was going on. But this might contain a clue, so I let you know about it.

  • Is there anything stopping you from copying the repo out to another machine, doing it there, and copying it back? – ethanwu10 Jun 8 '16 at 20:07
  • That'd be pretty much like doing the cleanup using my laptop to access the files via ssh. (Don't confuse this with logging in via ssh and running the command from there.) But I don't see any reason this isn't possible. What's the limiting thing here? It can't be ram because my laptop only has 16 GB and no swap, wheres my raspi now has a little more than double that when including swap. It can't be CPU power because that'd just make it take longer. – UTF-8 Jun 8 '16 at 20:45
  • If you just need to get the job done, you don't have to run the gc command on the RPi, but if your question is specifically about doing it on the Pi, then you might want to clarify – ethanwu10 Jun 9 '16 at 0:44
  • What about just deleting that file? You could do git gc and just add it again afterwards (if needed). Not the most elegant way but pragmatical. – duenni Jun 10 '16 at 11:20
  • @duenni I don't want to delete that file. It's one of the most important files I have on my computer and of course I want it in git since it changes from time to time. It's just that I suspect tracking this file makes git unable to clean the git repo on my raspi for some reason. I don't really know, though. The error message isn't very descriptive. It could be a big object file just as well. There is a 4.8 GB object file which probably only holds that one 4.8 GB file and there is a 6 GB file in objects/pack. – UTF-8 Jun 10 '16 at 11:33

It was a bug in git. I told the guys from the git mailing list about the problems and they fixed it. The patches are in the newest few releases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.