0

大家好,我目前正在尝试将 git repo 从 bitbucket 迁移到 github.com,其中包含 >21,000 个标签和 >800 个分支,并遇到以下问题。

  • git push --mirror origin命令因内部服务器错误而失败。
    • 然而,单个分支可以一次成功地推送一个。示例git push origin develop将推送该空目录的开发分支。
  • 没有大于 50MB 的文件需要大文件存储。我们之前运行bfg来清理一些在 git 历史记录中不需要的文件。

我们可以进行一些清理以将分支总数限制为大约 500 个(包括发布分支),但内部打包需要所有标签。

有没有办法在git push --mirror origingithub 没有内部服务器错误的情况下运行?

注释 http 协议设置为 500MB,因此写得更快。SSH 会写得很慢,所以我更喜欢 HTTP 协议,除非有人对如何提高 SSH 传输速度有建议。

用于加速 https 的 Git 配置设置(否则以 214KiB/s 的速度上传大约需要 25-45 分钟 git config --global http.postBuffer 524288000

带有 https 的伪代码

git clone --mirror <https://git.bitbucket.url>
git remote set-url origin <https://github.com.url>
git push --mirror

Pushing to https://github.com/<USER_ID>/YOUR_APP.git
Enumerating objects: 308119, done.
Counting objects: 100% (308119/308119), done.
Delta compression using up to 12 threads
Compressing objects: 100% (91394/91394), done.
Writing objects: 100% (308119/308119), 350.82 MiB | 529.07 MiB/s, done.
Total 308119 (delta 205766), reused 308103 (delta 205750), pack-reused 0
POST git-receive-pack (370558594 bytes)
remote: Resolving deltas: 100% (205766/205766), done.
remote: Internal Server Error
Everything up-to-date

当使用上述相同的方法但使用 SSH 时,上传速度要慢得多(~200-400 KiB/s),但每个标签和分支都会出现错误。(见下文)

[remote failure]        example_branch_v2 -> example_branch_v2 (remote failed to report status)

到目前为止,推送到 github.com 并执行此迁移的唯一方法是手动推送每个分支。如果这是唯一的解决方案,我需要编写一个迭代脚本。

有没有人以前有过这方面的经验,并且在配置方面取得了成功,可以让我--mirror直接将其推送到新的 github.com 存储库?

谢谢!

4

1 回答 1

1

迭代每个分支确实是第一种方法:

for branch in "$(git for-each-ref --format='%(refname:short)' refs/heads)"; do
    git push -u origin ${branch}
done

唯一的另一种方法是将捆绑包传输到服务器,这在此处是不可能的(github.com)。

于 2021-09-25T00:24:45.577 回答