Git将现有存储库推送到新的远程站点:远程主机关闭了与github.com的连接

问题描述

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

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

在回购的单独副本中:

$ 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.
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显示存储库为3.7GB,并且没有太大的单个文件。

有任何调试思路吗?谢谢。

解决方法

检查问题是否仍然存在:

  • 使用最新的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推送处理而言不会太大。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...