如何将 Bitbucket 存储库导入我的 Github 帐户?

How to import a Bitbucket repo into my Github account?

我在 Bitbucket 上有一个大型存储库,我需要将其导入 Github。回购协议包含大量我不想丢失的历史信息。我四处搜索,找不到解释该过程的权威资源。我是否漏掉了一些明显的东西?

提前致谢!

Am I missing something obvious?

在许多情况下,只需添加一个新的遥控器并向其推送即可完成您想要的操作:

git remote add github git@github.com:user/repo.git
git push github master

这会将您的 master 分支推送到 GitHub。你可以用类似的方式推送其他分支,你可以用 git push github --tags.

推送你的标签

更全面的选择是使用--mirror选项,例如

# Add the github remote as above, then
git push --mirror github

来自 the documentation:

--mirror

Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.

请注意,这意味着 --force,因此请谨慎使用。一些用户喜欢从远程的新裸克隆执行此操作(即首先执行 git clone --bare git@bitbucket.com:user/repo.git,然后从新创建的裸存储库执行其余步骤)。