gitgithubgithub-for-windows

Git Push remote: fatal: pack exceeds maximum allowed size


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.


Solution

  • 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)

    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);
        }