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:
- You’ll need TortoiseHg 0.9.3 or later. Get the latest version.
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-gitin this example.
> hg clone http://bitbucket.org/durin42/hg-git/ D:\TortoiseHg\hg-git
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.
Navigate down to the
[extensions]section and add this line to that section:
hggit = D:\TortoiseHg\hg-git
D:\TortoiseHg\hg-gitis 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.
Now you can clone a Git repository like so:
> hg clone git://github.com/richhickey/clojure.git D:\TargetDirectory
The result is you’ll have a Mercurial enabled repository at
D:\TargetDirectory. You can
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.