Accessing a Git repository with TortoiseHg on Windows

— richardwb on Friday, April 09, 2010 @ 10:31

If you're using Hg and you want to get hold of a Git repository there is an extension, hg-git, that lets you do this.

On Windows the installation process for this hasn't always been the easiest, as you needed to first install the dulwich Python library (which I always seemed to have trouble doing) and then hg-git. The TortoiseHg guys have made this a lot easier in recent versions of TortoiseHg, as they now include the dulwich libraries.

So, step by step:

  1. You'll need TortoiseHg 0.9.3 or later. Get the latest version.
  2. Bring up a command line and enter this line to clone the latest hg-git to your desired directory (this is "installing" hg-git). I'll use D:\TortoiseHg\hg-git in this example.

    > hg clone D:\TortoiseHg\hg-git
  3. Open up your user-specific Mercurial.ini. The location of this file may change occasionally, read the Mercurial docs if you have trouble finding it.
    On Windows Vista and Windows 7 this file is typically located at:


    while on Windows XP you'll find it at:

    C:\Documents and Settings\YourUsername\Mercurial.ini

    Alternatively, bring up the Windows "Run" dialog and enter:


    which will work on all recent Windows platforms.

  4. Navigate down to the [extensions] section and add this line to that section:

    hggit = D:\TortoiseHg\hg-git

    Where D:\TortoiseHg\hg-git is the directory you cloned hg-git to earlier. This line may already exist or may be commented out with a semicolon, in that case just remove the semicolon and update the directory.

  5. Now you can clone a Git repository like so:

    > hg clone git:// D:\TargetDirectory
  6. The result is you'll have a Mercurial enabled repository at D:\TargetDirectory. You can push, pull, and generally treat it as an Hg repository. Try

    > hg help hggit

for additional help and information, or check the HgGit page on the Mercurial wiki.

comments powered by Disqus