56

是否有有效的工作流程将主要托管在使用 Hg 的 bitbucket 上的项目镜像到 github?

4

7 回答 7

39

您可以使用以下工具hg-git

  • 在您可以推送访问的某个地方设置一个 Git 存储库,
  • 然后hg push [path]从您的项目中运行。例如:
$ cd hg-git # (a Mercurial repository)
$ hg bookmark -r default master # make a bookmark of master for default, so a ref gets created
$ hg push git+ssh://git@github.com/schacon/hg-git.git
$ hg push

这会将我们所有的 Mercurial 数据转换为 Git 对象并将它们推送到 Git 服务器。
您也可以将该路径放在 的[paths]部分中.hg/hgrc,然后按名称推送到它。

hg-git

于 2010-04-19T19:49:27.287 回答
13

如果您将 Mercurial 用于项目,您可以快速轻松地制作项目的 git 镜像,以便 git 用户可以做出贡献。hg-git我在 GitHub 上 创建了一个关于使用来管理 Mercurial 镜像的教程。

它涵盖了如何开始使用 GitHub 帐户,如何将项目从 Mercurial 推送到 GitHub,以及如何接受来自 GitHub 的贡献(拉取请求)。这是博客文章的链接:http: //hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/存档于http://web.archive.org/web/20100811223113/ http://hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/

于 2010-04-19T20:51:04.073 回答
12

'git-remote-hg' 是来自 Git 项目的半官方 Mercurial 桥,一旦安装,它允许您克隆、获取和推送到 Mercurial 存储库,就像它们是 Git 一样:

git-remote-hg添加到您的 bin 路径。然后您可以按照github 上的说明进行镜像。

git clone --mirror  hg::https://bitbucket_repo

然后,进入你的克隆仓库

git remote set-url --push origin https://github.com/exampleuser/mirrored

最后,同步你的镜像

git fetch -p origin
git push --mirror
于 2014-04-21T13:59:49.000 回答
6

截至 2013 年 7 月,有一个 Web 服务BitSyncHub,用于通过 BitBucket 接收后挂钩自动执行此过程。不过,您需要向您的 GitHub 存储库授予服务写入权限(将bitsynchub添加为贡献者)。

于 2013-12-06T22:30:14.637 回答
3

我从 2019 年 2 月开始报告。我刚遇到这个问题,按照@vonc 的建议使用hg-git,并填写了一些缺失的步骤以使其正常工作。在这里,我将提供更详细的指南:

  1. 安装 hg-git,方法是在某个地方克隆它的存储库,并使 ~/.hgrc 文件中的“扩展”部分看起来像这样:
[extensions]
hggit = [path-to]/hg-git/hggit

我在源代码库中找到了最新的安装说明:https ://bitbucket.org/durin42/hg-git 。所以请注意这一点。

  1. 如果还没有安装德威pip install dulwich: .

  2. 在 GitHub 上创建一个新的空存储库,例如https://github.com/user/git-mirror

  3. 克隆 hg 源代码库,并将其推送到 git 镜像:

$ hg clone https://bitbucket.org/user/hg-source
$ cd hg-source
$ hg push git+ssh://git@github.com/user/git-mirror.git
于 2019-02-03T01:12:09.983 回答
1

另一种快速转换的可用解决方案:https ://github.com/frej/fast-export

于 2014-03-23T09:10:52.557 回答
0

您可以使用Git-hg 镜像服务来执行此操作(包括将 GitHub 存储库镜像到 Bitbucket,或双向同步)。

于 2018-05-12T17:23:01.727 回答