Mirroring a HG project from Bitbucket to Github

As of July 2013 there is BitSyncHub a 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 bitsynchub as a contributor).


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-git to manage Mercurial mirrors on GitHub.

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/


'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:

Add git-remote-hg to your bin path. Then you can mirror as mentioned on 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

You could use a tool like hg-git to:

  • setup a Git repository somewhere that you have push access to,
  • and then run hg push [path] from within your project. For example:
$ 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/hgrc and then push to it by name.

hg-git