git - 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,并且没有非常大的单个文件。
任何调试想法?谢谢。
解决方案
检查问题是否仍然存在:
- 使用最新的 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 推送来说不会“太大”。
推荐阅读
- linux - systemd 无法执行带有预期参数的命令
- javascript - 移动浏览器上的服务工作者 JavaScript 问题
- java - 在不使用条件语句的情况下查找三个随机生成的数字中的最高、第二高和最低
- javascript - 从 Angular 组件访问 Electron API
- opengl - OpenGL Light随着移动对象移动,即使它不应该
- haskell - `Compose` 与 `Contravariant` 和 `Functor` 的重叠实例
- reactjs - React.js 和 Typescript 返回获取 API 响应的类型?
- google-cloud-platform - 在我使用当前配额(即 0)之前,谷歌云不会让我增加 GPU 配额?
- python - 根据当前值更改字典中的多个值
- php - 如何在 PHP 中声明一个 100x100 的矩阵