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.

d7l2k4
  • 175
  • 1
  • 2
  • 14

1 Answers1

10

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);
    }
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi. So if the project has several folders, should I make a repository for each folder? – d7l2k4 Apr 14 '21 at 22:20
  • Also how do I install git-sizer on Windows? I have Visual Studio Code and git bash. – d7l2k4 Apr 14 '21 at 22:21
  • 2
    @d7l2k4 git-sizer is just an executable that you can download from the release page: https://github.com/github/git-sizer#getting-started – VonC Apr 14 '21 at 22:24
  • 1
    @d7l2k4 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. – VonC Apr 14 '21 at 22:26
  • It's prestashop. So ... yes I understand. – d7l2k4 Apr 14 '21 at 22:27
  • One final question @VonC ... 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? – d7l2k4 Apr 14 '21 at 22:28
  • 2
    @d7l2k4 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://stackoverflow.com/a/3639154/6309. Other options: https://stackoverflow.com/a/4114122/6309 – VonC Apr 14 '21 at 22:34
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/231151/discussion-between-d7l2k4-and-vonc). – d7l2k4 Apr 14 '21 at 23:05
  • 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. – MbaiMburu Jul 20 '22 at 06:48