将包含所有分支和完整历史的Git存储库从Bitbucket移动到GitHub的最佳方法是什么?

是否有我必须使用的脚本或命令列表?


当前回答

如果你想要将本地Git存储库移动到另一个上游,你也可以这样做:

获取当前远程URL:

git remote get-url origin

将显示如下内容: https://bitbucket.com/git/myrepo

设置新的远程存储库。

git remote set-url origin git@github.com:folder/myrepo.git

现在推送当前(开发)分支的内容:

Git push -set-upstream源码开发

现在,您在新的远程中拥有了分支的完整副本。

可选地,返回到这个本地文件夹的原始git-remote:

git remote set-url origin https://bitbucket.com/git/myrepo

它的好处是,你现在可以从GitHub的另一个文件夹中获得新的Git存储库,这样你就有两个本地文件夹都指向不同的远程,以前的(Bitbucket)和新的都可用。

其他回答

如果你想要将本地Git存储库移动到另一个上游,你也可以这样做:

获取当前远程URL:

git remote get-url origin

将显示如下内容: https://bitbucket.com/git/myrepo

设置新的远程存储库。

git remote set-url origin git@github.com:folder/myrepo.git

现在推送当前(开发)分支的内容:

Git push -set-upstream源码开发

现在,您在新的远程中拥有了分支的完整副本。

可选地,返回到这个本地文件夹的原始git-remote:

git remote set-url origin https://bitbucket.com/git/myrepo

它的好处是,你现在可以从GitHub的另一个文件夹中获得新的Git存储库,这样你就有两个本地文件夹都指向不同的远程,以前的(Bitbucket)和新的都可用。

最简单的方法:

git remote rename origin repo_bitbucket

git remote add origin https://github.com/abc/repo.git

git push origin master

一旦推送到GitHub成功,通过运行以下命令删除旧的远程:

git remote rm repo_bitbucket

这很简单。

在GitHub中创建一个新的空存储库(没有README或许可证,您可以稍后添加它们),将显示以下屏幕。 在import code选项中,粘贴你的Bitbucket存储库的URL和voilà!!

如果你在GitHub上找不到“导入代码”按钮,你可以:

直接打开GitHub Importer并输入URL。它看起来像: 给它一个名字(或者它会自动导入这个名字) 选择Public或Private存储库 单击“开始导入”

2016年5月,GitHub宣布能够“导入带有大文件的存储库”。

你可以参考GitHub页面“复制存储库”

它使用:

Git克隆——镜像:克隆每个引用(提交,标签,分支) Git push—mirror:用于推送所有内容

这将给予:

git clone --mirror https://bitbucket.org/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repository

cd repository-to-mirror.git
git remote set-url --push origin https://github.com/exampleuser/mirrored
# Set the push location to your mirror

git push --mirror

正如L S在评论中指出的那样:

使用MarMass描述的GitHub导入代码功能更容易。 参见https://github.com/new/import 除非…您的回购包括一个大文件:问题是,导入工具将失败,没有一个明确的错误消息。只有GitHub支持才能诊断出发生了什么。