将Bitbucket Mercurial存储库转换为Git.维护分支机构和历史记录.在线解决方案 [英] Convert Bitbucket Mercurial repository to Git. Maintain branches and history. Online solution

查看:93
本文介绍了将Bitbucket Mercurial存储库转换为Git.维护分支机构和历史记录.在线解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Bitbucket Mercurial存储库(Hg存储库)转换为Git存储库?我想保留分支并提交历史记录.

How do I convert a Bitbucket Mercurial repository (Hg repository) to a Git repository? I want to keep branches and commit history.

推荐答案

我发现在保留所有分支的同时将Mercurial存储库转换为Git的唯一方法是使用GitHub的导入器.这也是最简单的方法,因为它们都是在线完成的.无需本地安装,无需命令行.

The only way I found to convert a Mercurial repo to Git, while keeping all the branches, was to use GitHub's importer. This was also the easiest since it's all done online. Nothing local to install, no command line stuff.

主要思想

使用Github的进口商将Bitbucket Mercurial存储库转换为GitHub Git存储库.然后将其重新导入Bitbucket.

Use Github's importer to convert Bitbucket Mercurial repo to GitHub Git repo. Then import that back into Bitbucket.

步骤

在Bitbucket中:

重命名要转换的Mercurial存储库(如果希望新的Git存储库具有与Mercurial存储库相同的名称).您可以在设置"中执行此操作.例如,将其命名为projectname_mercurial.

Rename the Mercurial repository that you want to convert (if you want the new Git repo to have the same name as your Mercurial repo did). You do this in Settings. For example, name it projectname_mercurial.

获取存储库的克隆URL. (在存储库的主页上,单击克隆"并仅获取URL,例如 https://username @ bitbucket. org/username/projectname )

Grab the Clone URL of the repository. (On the repo's main page, click Clone and grab just the URL, like https://username@bitbucket.org/username/projectname )

在Github中:

如果您还没有帐户,请创建一个 https://github.com

If you don't already have an account, create one https://github.com

使用GitHub导入程序 https://github.com/new/import

Use the GitHub importer https://github.com/new/import

  • 输入来自Bitbucket的克隆URL.
  • 给它起个名字.到底什么都没关系.
  • 将其设置为私有.默认为公开!

  • Enter the Clone URL from Bitbucket.
  • Give it a name. It doesn't really matter what.
  • Set it to private. Public is default!

注意:您可以直接将密码添加到URL ,这样就无需在下面的步骤中输入您的凭据(由于下面的@ keith-turkowski注释).因此,通过在用户名之后添加:password来更改您的bitbucket克隆URL,如下所示: https://username: password@bitbucket.org/username/projectname

NOTE: You can add your password to the URL directly, which will then avoid the need to enter your credentials in the steps below (thanks to @keith-turkowski comment below). So change your bitbucket clone url by adding :password after username, like this: https://username:password@bitbucket.org/username/projectname

开始在Github中导入

等待!提示您可以的页面不要关闭(我们会通过电子邮件发送给您...).等待它询问您回购凭证.这可能需要几分钟.然后输入凭据. (假设它需要凭据.)

WAIT! Do not close the page when it says that you can (We'll email you...). Wait for it to ask you for the repo credentials. This can take several minutes. Then enter the credentials. (Assuming it requires credentials.)

再次等待!再次会要求您提供回购凭证.至少每次都对我有用. (请参见上面有关将密码直接添加到URL的注释,因此它不会询问您.)

WAIT AGAIN! It's again going to ask for your repo credentials. At least it did for me, every time. (See note above on adding your password directly to URL so it does not ask you.)

现在,您要等到完成为止.您会收到一封电子邮件.

Now you wait until it's done. You will get an email.

完成后,获取GitHub项目URL.当您位于GitHub项目页面上时,这只是网页URL.

When it's done, grab the GitHub project URL. It's just the webpage URL when you are on the GitHub project page.

在Bitbucket中:

使用"+">导入">存储库"菜单选项创建一个新的存储库.

Create a new repository using the "+" > Import > Repository menu option.

  • 输入GitHub项目URL
  • 选中需要身份验证",输入您的GitHub凭据.
  • 输入新的Git存储库名称(例如,重命名之前的Mercurial项目的名称.)
  • 将访问级别保留为私有.

在Github中:

删除导入的项目: 项目的设置"标签>删除此存储库

Delete the imported project: Project's Settings tab > Delete this repository

这篇关于将Bitbucket Mercurial存储库转换为Git.维护分支机构和历史记录.在线解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆