How do I convert a git repository to mercurial?

The hg convert utility isn't on by default after installation. In order to set it as such add the following to your .hgrc file.

[extensions]
hgext.convert=

If you're using TortoiseHg on Windows then this file resides in your home directory as mercurial.ini. After this setting change you will be able to use the hg convert utility.


By using the Mercurial Convert extension

Add the following lines to your .hgrc or to enable the extension :

[extensions]
hgext.convert=

And typing a

cd src
hg convert --datesort . dst

(even though it can lead to some issues...)

Note:: metrix reports that this might not work:

     hg convert --datesort src dst

Note: there happens to be a bug with hg convert if you perform this command from a directory other than the source directory.
You will get the following error:

abort: cannot read tags from git-repo4/.git

Confirmed with git 1.7.9 and Mercurial 2.6.2 on Windows XP


You may want to look at the http://hg-git.github.com/ utility: a Git plugin for Mercurial

This plugin is originally developped by the guys of GitHub, and allows the convert from git<->mercurial losslessly. In theory, you could even be able to clone the hg repository.


Distributed revision control with Mercurial states:

The revision control tools supported by convert are as follows:

  • Subversion
  • CVS
  • Git
  • Darcs

So maybe you don’t need any additional tool?