Mercurial and Git in one repository

I have a personal project hosted at bitbucket using Mercurial as the version control system. Since I started that project, I’ve been using GitHub for everything. I just found hg-git instructions on github.com. It is pretty awesome.

For my purposes, it allows me to maintain the project on two remote servers, one running Mercurial, the other running Git.

To see how it works, first install hg-git:

$ sudo easy_install hg-git

Then, edit your ~/.hgrc settings, adding to the [extensions] section:

[extensions]                                                                                                                                      
hgext.bookmarks =
hggit =

Also, be sure your ~/.hgrc contains a valid email address:

[ui]
username = Jim Schubert <james.schubert@gmail.com>

Now, you can create a repository on github.com and push your Mercurial commits:

$ cd ~/projects/project_name
$ hg bookmark -r default master
$ hg push git+ssh://git@github.com/username/project_name.git
$ hg push

If you’re only planning on using Mercurial to push changes to github or some other Git host, you can add that path to ~/.hgrc:

[paths]
default-push = git+ssh://git@github.com/username/project_name.git