Using Git repositories with Mercurial on Windows

I’ve been using Mercurial as my source control for a few weeks now, but wanted to get some source code from GitHub. I’d rather not have to install the git client and server, and those clever people at GitHub have catered for this nicely with the Hg-Git mercurial plugin. Trouble is, for novices, the instructions aren’t very clear, so for those that stumble across this site from time to time, here’s the simple instructions to follow:

The Pre-requisites are Python, TortoiseHG and Mercurial, which you will probably already have. Fortunately these are available in a single package TortoiseHg 2.0.5 with Mercurial 1.8.4 for Windows.

Once you’ve installed and restarted Windows, these are the next steps:

  • Open a Command Prompt and run
    easy_install hg-git

    (this is a Python command in case you were wondering – it will run a python script and install Dulwich and hg-git)

  • Edit your .hgrc file
    notepad %userprofile%\.hgrc

    (if you don’t have a .hgrc file, you will be asked if you want to create one)

  • Enter the following lines into the file (If you already have a .hgrc file with an [extensions] line in, then obviously don’t repeat that line, put the other two lines below it)
    [extensions]
    hgext.bookmarks =
    hggit = C:\Python26\Lib\site-packages\hg_git-0.2.6-py2.6.egg\hggit

    (This is assuming that the Python installed is v2.6 and the hg-git extension is v0.2.6 – check the path to make sure you’ve specified it correctly)

  • To check it’s all working correctly, go to a Command Prompt and change to a directory where you wish to download source code to, and then try to download the source for hg-git:
    cd /d d:\Projects
    hg clone git://github.com/schacon/hg-git.git

Hopefully you won’t see any errors and when you list the hg-git folder, you’ll find a bunch of files and folders with the source code in.

Simple, eh?

Hg-Git mercurial plugin

Comments are closed