Git Push 远程:致命:包超出允许的最大大小

问题描述 投票:0回答:2

我接到了一个大项目。客户想将其添加到github。

我是一点一点添加的。然后发生的事情是我太贪心了,一次添加了太多文件。现在,无论我尝试什么,我都会不断收到此错误。我该如何解决这个问题?我试图回滚,但也许我做错了。

$ 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'

我正在使用 Visual Studio Code 和 git bash 上传。

git github github-for-windows
2个回答
13
投票

首先,您可以使用 git-sizer 来了解当前本地存储库中哪些内容占用了太多空间(您无法推送)

  • 如果是因为提交太大,你可以:

    • git reset @~
      取消该提交
    • 重做几个较小的提交
    • 尝试再推一次
  • 如果是因为文件太大,你可以尝试激活Git LFS,但这有配额限制,上面可能包含非免费服务。

更一般地说,一个“大型项目”可能需要分成多个 Git 存储库。


请注意,在 Git 2.36(2022 年第 2 季度)中,当“

index-pack
”由于传入数据超过允许的最大输入大小而死亡时,它将在错误消息中包含限制值

了解远程限制后,您将能够更有效地拆分提交。 (假设远程服务器确实使用Git 2.36+)

请参阅 Matt Cooper (vtbassmatt)

commit 0cf5fbc(2022 年 2 月 24 日)。
(由 Junio C Hamano --
gitster
--
合并于 commit 283e4e7,2022 年 3 月 6 日)

index-pack
:澄清违反的限制

帮助者:Taylor Blau
帮助者:Derrick Stolee
签署人:马特·库珀

作为对用户的一个小礼貌,请报告违反了哪些限制。
当推送超过服务器定义的限制时,这特别有用,因为用户不太可能配置该限制(他们的主机已配置)。

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

0
投票

在 gitlab 中,您可以在“帐户和限制设置”部分进行设置https://docs.gitlab.com/ee/administration/settings/account_and_limit_settings.html –“最大推送大小 (MiB)”参数

© www.soinside.com 2019 - 2024. All rights reserved.