首页 > 解决方案 > Git 将现有仓库推送到新远程:远程主机关闭与 github.com 的连接

问题描述

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

$ 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

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

任何调试想法?谢谢。

标签: gitgithubgitlab

解决方案


检查问题是否仍然存在:

  • 使用最新的 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 推送来说不会“太大”。


推荐阅读