Is there an efficient workflow to mirror a project that is mainly hosted on bitbucket using Hg, to github?
7 Answers
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://git@github.com/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.

- 1,262,500
- 529
- 4,410
- 5,250
-
Thanks. I did take a brief look at hg-git, but I see that it is still in an alpha state. I tried installing it in cygwin but I am having some stability issue with it at the moment. Provided this works, though, it is definitely a useful tool in the workflow. – Santa Apr 19 '10 at 20:23
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/

- 2,583
- 4
- 21
- 29

- 19,642
- 2
- 51
- 44
'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

- 31,383
- 12
- 95
- 128
-
1This is much better than accepted answer as the result will be a true mirror with all tags and branches. – Kentzo Nov 01 '17 at 01:15
-
check your OS repos, ie fedora package is available: `dnf install -y git-remote-hg` – Alec Istomin Jan 30 '20 at 23:17
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).

- 13,235
- 6
- 79
- 81
I'm reporting from Feb 2019. I just encountered this problem, followed @vonc's suggestion to use hg-git, and filled a few missing steps to make it work. Here I'll provide a more detailed guide:
- Install hg-git by cloning its repository somewhere and making the 'extensions' section in your ~/.hgrc file look something like this:
[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.
Install dulwich if not already:
pip install dulwich
.Create a new empty repository on GitHub, for example https://github.com/user/git-mirror.
Clone the hg source repository, and push it to the git mirror:
$ hg clone https://bitbucket.org/user/hg-source
$ cd hg-source
$ hg push git+ssh://git@github.com/user/git-mirror.git
One more available solution to quickly convert: https://github.com/frej/fast-export

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

- 2,693
- 2
- 24
- 43