繁体   English   中英

如何将 Bitbucket 存储库迁移到 Github?

[英]How to migrate a Bitbucket repository to Github?

我想将包含多个分支的旧 Bitbucket 存储库迁移到 Github。 为此,我遵循了以下描述:

# add remote github repository
$ git remote add upstream https://github.com:USER/PROJECT.git
# push all branches <-- doesn't work
$ git push upstream master
$ git push --tags upstream

只有master分支被推送到 Github 存储库(也适用于git push --all upstream )。

为了将所有分支推送到 Github,我需要单独checkout它们并执行git push upstream

如何在不先checkout出所有分支的情况下将所有分支推送到 Github?

您可以使用此单个命令来完成。

git push REMOTE --mirror

你可以在这里阅读更多关于它的信息

请按照以下步骤操作。

  1. 镜像源代码库。

    git clone --mirror https://url-of-the-source-git-repo.git

  2. Go 到新克隆的 repo

    cd to-your-git-repo-folder.git

  3. 设置新的遥控器 url。

    git remote set-url --push origin https://url-of-the-destination-git-repo.git

  4. 推送到新的仓库

    git push --mirror

通过遵循这些命令,您将迁移到包含所有分支和提交的新仓库。

首先确保您已获取所有分支

git fetch --all

然后将所有分支推送到新的远程

git push upstream --all

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM