git 将 HG 项目从 Bitbucket 镜像到 Github

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2670158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:14:18  来源:igfitidea点击:

Mirroring a HG project from Bitbucket to Github

gitmercurialworkflowgithubbitbucket

提问by Santa

Is there an efficient workflow to mirror a project that is mainly hosted on bitbucket using Hg, to github?

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

采纳答案by VonC

You could use a tool like hg-gitto:

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

  • setup a Git repository somewhere that you have push access to,
  • and then run hg push [path]from within your project. For example:
  • 在您可以推送访问的某个地方设置一个 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://[email protected]/schacon/hg-git.git
$ hg push

This will convert all our Mercurial data into Git objects and push them up to the Git server.
You can also put that path in the [paths]section of .hg/hgrcand then push to it by name.

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

hg-git

hg-git

回答by Steve Losh

If you use Mercurial for a project you can quickly and easily make a git mirror of your project so that git users can contribute. I created a tutorial about using hg-gitto manage Mercurial mirrors on GitHub.

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

It covers how to get started with a GitHub account, how to push up a project from Mercurial to GitHub, and how to accept contributions (pull requests) from GitHub. Here's a link to the blog post: http://hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/archived at http://web.archive.org/web/20100811223113/http://hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/

它涵盖了如何开始使用 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/

回答by jbtule

'git-remote-hg' is the semi-official Mercurial bridge from Git project, once installed, it allows you to clone, fetch and push to and from Mercurial repositories as if they were Git ones:

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

Add git-remote-hgto your bin path. Then you can mirror as mentioned on github.

git-remote-hg添加到您的 bin 路径。然后你可以像github 上提到的那样镜像。

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

then, go into your cloned repo

然后,进入你的克隆仓库

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

finally, sync your mirror

最后,同步你的镜像

git fetch -p origin
git push --mirror

回答by kynan

As of July 2013 there is BitSyncHuba web service for automating this process via a BitBucket post-receive hook. You will need to grant the service write permission to your GitHub repository though (add bitsynchubas a contributor).

截至 2013 年 7 月,BitSyncHub是一项 Web 服务,用于通过 BitBucket post-receive hook 自动执行此过程。不过,您需要向您的 GitHub 存储库授予服务写入权限(将bitsynchub添加为贡献者)。

回答by qobilidop

I'm reporting from Feb 2019. I just encountered this problem, followed @vonc's suggestionto use hg-git, and filled a few missing steps to make it work. Here I'll provide a more detailed guide:

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

  1. Install hg-git by cloning its repositorysomewhere and making the 'extensions' section in your ~/.hgrc file look something like this:
  1. 通过将其存储库克隆到某个位置并使 ~/.hgrc 文件中的“扩展”部分看起来像这样来安装 hg-git :
[extensions]
hggit = [path-to]/hg-git/hggit

I found the most up-to-date installation instructions in the source repository: https://bitbucket.org/durin42/hg-git. So keep an eye that.

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

  1. Install dulwichif not already: pip install dulwich.

  2. Create a new empty repository on GitHub, for example https://github.com/user/git-mirror.

  3. Clone the hg source repository, and push it to the git mirror:

  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://[email protected]/user/git-mirror.git

回答by Stefan Gloutnikov

One more available solution to quickly convert: https://github.com/frej/fast-export

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

回答by Piedone

You can use the Git-hg Mirror serviceto do this (including mirroring a GitHub repo to Bitbucket, or syncing bidirectionally).

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