2

This error has been bothering me for quite a long time now (several months), and everything I could find (either here on SO or on the Internet) has been solving nothing.

I have a git repository with a big history. So big that it's impossible to clone it. This is not what I want to address here, but specifying it might help you understand the problem.

Using git version 1.9.5, every time I git pull, git tells me: "Auto packing the repository for optimum performance. You may also run "git gc" manually. See "git help gc" for more information.". But it fails with this error: "fatal: Out of memory, malloc failed (tried to allocate 257539286 bytes)" (with the number of bytes increasing on every pull). I tried several times to run git gc manually, even with --prune=now, but I've been getting the same error.

Is there any configuration I can use to be able to git gc successfully? I don't mind if it takes several days to complete. (As said before, deleting the repo and cloning it back is not an option, since a clone leads to a timeout error from the proxy.)

V. Courtois
  • 315
  • 7
  • 20
  • Damn, it really sounds like you should look into `git lfs`. It's unconscionable to have a repository grow so large that you can't clone it anymore. – Blindy Aug 19 '20 at 16:38
  • https://stackoverflow.com/a/26464366/7976758, https://stackoverflow.com/search?q=%5Bgit%5D+gc+fatal%3A+Out+of+memory%2C+malloc+failed – phd Aug 19 '20 at 17:39
  • What version of Git are you using? (https://stackoverflow.com/a/50537861/6309) – VonC Aug 20 '20 at 06:30
  • git version is 1.9.5. But I can't really update it since it's the company stack. – V. Courtois Aug 20 '20 at 07:13
  • I confirm 1.9.5 is way too old, and the main reason behind your memory issue. – VonC Aug 20 '20 at 07:15
  • Is there no way out though? – V. Courtois Aug 20 '20 at 09:01
  • Prune your repository or update your git, those are the options you have. – Lasse V. Karlsen Aug 20 '20 at 09:13
  • @LasseV.Karlsen as I said in the question, pruning did not work either (out of memory too). Is there a way to prune without using gc? – V. Courtois Aug 20 '20 at 09:16
  • Unfortunately, the tool to maintain a git repository is git itself. Other tools will either shell out to git or use libraries like libgit2, which is based on the same source code. The main problem here is that you cannot fix your repository permanently **because there is nothing wrong with your repository**. The problem is in the tool, git. – Lasse V. Karlsen Aug 20 '20 at 09:18
  • The fix would be, as others have suggested, to move to git lfs. This should require first a one-time job of rewriting your repository to put large files into lfs, afterwards the git you have might work, but I suspect you will need to use a newer git to do this rewriting, otherwise you risk having the same problem there. – Lasse V. Karlsen Aug 20 '20 at 09:19
  • Also, software is something that updates regularly, so your company stack should need a revisit. Talk to your managers or whoever is managing that stack and tell them it is time to update git at least. I suspect your company stack has other issues as well if you can't even update git. – Lasse V. Karlsen Aug 20 '20 at 09:20
  • I agree. But this is not a solution to the question, so I'll let it open since I suspect there *is* a way to succeed in doing a gc even with my current setup (by tweaking git configs). – V. Courtois Aug 20 '20 at 09:54

0 Answers0