【问题标题】:How do I push a Git mirror in chunks?如何分块推送 Git 镜像?
【发布时间】:2017-03-31 20:57:26
【问题描述】:

我目前正在经历将一个大型 Git 项目迁移到 Git-LFS 的过程,其中包括重写整个 repo 历史以在 Git-LFS 中创建和包含某些文件。这部分流程没问题。

但是,我无法将新存储库推送到上游远程 (GitHub),因为它看起来太大而无法一次性推送:

PS > git push
Counting objects: 337130, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (73730/73730), done.
remote: fatal: pack exceeds maximum allowed size
fatal: sha1 file '<stdout>' write error: Broken pipe30 MiB/s
error: failed to push some refs to 'git@github.com:my-repo.git'

我尝试使用 HTTPS,结果相似:

PS > git push
Counting objects: 337130, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (73730/73730), done.
error: RPC failed; curl 55 SSL_write() returned SYSCALL, errno = 10053
fatal: The remote end hung up unexpectedly
Writing objects: 100% (337130/337130), 3.58 GiB | 388.62 MiB/s, done.
Total 337130 (delta 261838), reused 337130 (delta 261838)
fatal: The remote end hung up unexpectedly
Everything up-to-date

这似乎有点常见,there are some solutions available 包括指定一次上传的提交块。但是我的 repo 是一个镜像克隆,不适用于指定的 refspec:

PS > git push -u origin HEAD~5000:refs/heads/master
error: --mirror can't be combined with refspecs

关于如何将镜像存储库分块推送到远程上游的任何想法?

【问题讨论】:

    标签: git github


    【解决方案1】:

    通过在 git 配置中将 remote.<em>name</em>.mirror 设置为 false 来暂时禁用推送镜像。

    使用--mirror 推送只是推送所有引用(refs/ 下的所有内容),并将存储库配置为作为推送镜像有效地设置了--mirror 标志。为了推送一组有限的提交,您需要执行 git push <em>remote</em> <em>refspec</em> 事情,以便您的 refspec 可以引用足够小的一组提交。

    您可能也不想在这里使用-u,因为它为当前分支设置了上游,但推送镜像通常根本不使用上游。

    (一旦你在遥控器上有足够的提交,你可以重新启用推送镜像,因为从那里开始,你发送的“瘦包”应该更小:实际上很薄,而不仅仅是理论上的薄:-) .)

    【讨论】:

    • 你能告诉我如何暂时禁用推送镜像吗?
    • 在 git 配置中将 remote.&lt;name&gt;.mirror 设置为 false。见kernel.org/pub/software/scm/git/docs/git-config.html
    • 嗯好的。我也遇到了 refspecs 的问题。我们有大约 15k 次提交。您认为将其分成 3 或 4 次推送的简单方法是什么?
    • 很难知道在哪里划分东西。您可以使用git rev-list --count 查看从某个起点可以到达多少提交,也可以使用一些截止点,例如,git rev-list --count 8765432 ^2222223 会告诉您在这两点“之间”有多少提交(这里的222... 是提交已经推高,876... 是建议的下一批)。但这只是 commits 的数量,而不是 objects 的数量,更不用说有多大了。 [继续]
    • 可能有一些方法可以使用git pack-objects --thin 来构建一个“测试”包并检查它的大小,因此会自动调整到某个限制,但我不知道该怎么做.
    猜你喜欢
    • 1970-01-01
    • 2021-02-27
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多