【问题标题】:Git push Existing Repo to New Remote: Connection to github.com closed by remote hostGit 将现有仓库推送到新远程:远程主机关闭与 github.com 的连接
【发布时间】:2020-08-11 04:47:36
【问题描述】:

我有一个想要推送到新网址的现有仓库。我尝试了以下方法。

$ git remote set-url origin git@github.com:user/new-repo.git
$ git config --global http.postBuffer 1048576000
$ git config --global ssh.postBuffer 1048576000
$ git push --verbose
Pushing to github.com:user/new-repo.git
Enumerating objects: 2729, done.
Counting objects: 100% (2729/2729), done.
Delta compression using up to 24 threads
fatal: the remote end hung up unexpectedly
Connection to github.com closed by remote host.
error: pack-objects died of signal 2)
fatal: the remote end hung up unexpectedly

$ git repack
Enumerating objects: 2999, done.
Counting objects: 100% (2732/2732), done.
Delta compression using up to 24 threads
Compressing objects: 100% (2548/2548), done.
Writing objects: 100% (2732/2732), done.
Total 2732 (delta 1716), reused 0 (delta 0), pack-reused 0

$ git push --verbose
Pushing to github.com:user/new-repo.git
Enumerating objects: 2729, done.
Counting objects: 100% (2729/2729), done.
Delta compression using up to 24 threads
Compressing objects: 100% (1115/1115), 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:user/new-repo.git
! [remote rejected] master -> master (failed)
error: failed to push some refs to 'github.com:user/new-repo.git'

在单独的 repo 副本中:

$ git remote set-url origin https://github.com/user/new-repo.git
$ git remote -v
origin  https://github.com/user/new-repo.git (fetch)
origin  https://github.com/user/new-repo.git (push)

$ git push
Enumerating objects: 2729, done.
Counting objects: 100% (2729/2729), done.
Delta compression using up to 24 threads
Compressing objects: 100% (2106/2106), done.
Writing objects: 100% (2729/2729), 2.50 GiB | 3.01 MiB/s, done.
Total 2729 (delta 1723), reused 706 (delta 395), pack-reused 0
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

原始 repo 托管在 gitlab 上。使用 github 的导入功能也会失败,没有描述性消息。 Gitlab 显示 repo 为 3.7GB,并且没有非常大的单个文件。

任何调试想法?谢谢。

【问题讨论】:

    标签: git github gitlab


    【解决方案1】:

    检查问题是否仍然存在:

    • 使用最新的 Git 2.28
    • 使用 https URL(用于测试):git remote set-url origin https://github.com/user/new-repo.git
    • 使用新存储库中的小内容(同样,用于测试:第一次提交时只有几个小文件)

    最后一点似乎很中肯:

    remote: fatal: pack exceeds maximum allowed size
    

    尝试并确保您的第一次提交不会“太大”,以至于 GitHub 推送无法处理。

    【讨论】:

    • 我更新到 Git 2.28,结果没有变化。我的测试存储库推得很好。我将 https 结果添加到主帖。 https 结果不同,但不起作用。
    • @harkib 如果您的初始提交仅由几个文件组成,它会失败吗?
    • 如何让初始提交只有几个文件。感谢您的快速回复。
    • @harkib 创建本地存储库时,不要执行git add .(添加所有内容),只需添加几个文件(git add file1git add file2、 ...)。然后提交并推送。
    • 我有一个完整的回购。一切都已提交并推送到旧仓库。我在本地复制了 repo 并更改了 url。我将如何着手使对新仓库的初始提交更小?
    猜你喜欢
    • 2020-07-05
    • 2020-04-28
    • 2019-06-29
    • 1970-01-01
    • 2011-07-08
    • 2015-08-29
    • 1970-01-01
    • 2013-02-21
    • 2014-12-22
    相关资源
    最近更新 更多