Git Push remote: fatal: pack exceeds maximum allowed size
Asked Answered
C

1

8

I received a large project. Client wanted to add it to github.

I was adding bit by bit. Then what happened was I got greedy and added too many files at once. Now, no matter what I try, I keep getting this error. How can I fix this? I tried to roll back but maybe I did it wrong.

$ git push
Enter passphrase for key '/c/Users/guestaccount/.ssh/id_rsa':
Enumerating objects: 35931, done.
Counting objects: 100% (35931/35931), done.
Delta compression using up to 12 threads
Compressing objects: 100% (35856/35856), done.
remote: fatal: pack exceeds maximum allowed size
fatal: sha1 file '<stdout>' write error: Broken pipe
error: remote unpack failed: index-pack abnormal exit
To github.com:(mygithubid)/(repo).git
 ! [remote rejected]   main -> main (failed)
error: failed to push some refs to 'github.com:(mygithubid)/(repo).git'

I am using Visual Studio Code and git bash to upload.

Chummy answered 14/4, 2021 at 5:51 Comment(0)
A
13

First, you can use git-sizer to get an idea of what is taking too much space in your current local repository (that you fail to push)

  • if it is because of a commit too big, you can:

    • git reset @~ to cancel that commit
    • remake several smaller commits
    • try and push again
  • if it is because of a file too big, you can try and activate Git LFS, but that is limited by quota and going above might include a non-free service.

More generally, a "large project" might need to be split up into several Git repositories.


Note tat, with Git 2.36 (Q2 2022), when "index-pack" dies due to incoming data exceeding the maximum allowed input size, it will include the value of the limit in the error message.

You will be able to split your commits more effectively knowing the remote limit. (Assuming the remote server does use Git 2.36+)

See commit 0cf5fbc (24 Feb 2022) by Matt Cooper (vtbassmatt).
(Merged by Junio C Hamano -- gitster -- in commit 283e4e7, 06 Mar 2022)

index-pack: clarify the breached limit

Helped-by: Taylor Blau
Helped-by: Derrick Stolee
Signed-off-by: Matt Cooper

As a small courtesy to users, report what limit was breached.
This is especially useful when a push exceeds a server-defined limit, since the user is unlikely to have configured the limit (their host did).

    if (max_input_size && consumed_bytes > max_input_size) {
        struct strbuf size_limit = STRBUF_INIT;
        strbuf_humanise_bytes(&size_limit, max_input_size);
        die(_("pack exceeds maximum allowed size (%s)"),
            size_limit.buf);
    }
Abnormity answered 14/4, 2021 at 6:42 Comment(9)
Hi. So if the project has several folders, should I make a repository for each folder?Chummy
Also how do I install git-sizer on Windows? I have Visual Studio Code and git bash.Chummy
@Chummy git-sizer is just an executable that you can download from the release page: github.com/github/git-sizer#getting-startedAbnormity
@Chummy Making a repository per folder is not necessary, unless each folder is huge, and quite independent one from another. If those folders are part of the same project, they should be part of the same Git repository. If those folders represent a "distinct" part of the project (like a front-end vs. a backend), then, for size and management reason, you might consider splitting them in their own separate repository.Abnormity
It's prestashop. So ... yes I understand.Chummy
One final question @Abnormity ... how do I roll back commits? I've made two folders and have been moving over a few folders at a time and committing. git reset does the job?Chummy
@Chummy If you don't mind resetting a few commits back (make sure to do a backup first in case the result is not satisfactory), a reset --hard is a good way to get back to a previous state: https://mcmap.net/q/73378/-reverting-to-a-specific-commit-based-on-commit-id-with-git-duplicate. Other options: https://mcmap.net/q/11819/-how-do-i-revert-a-git-repository-to-a-previous-commitAbnormity
Let us continue this discussion in chat.Chummy
The culprit is an extremely huge file that exceeds the limits set on your repository or gitlab. Mine was a 225MB of an audio file. It worked after removing it.Intellect

© 2022 - 2024 — McMap. All rights reserved.