This tutorial will show how to install and configure TortoiseHg to talk to an existing Git repository. It lets you use Mercurial as an Git client thus allowing version control of your changes locally while still allowing you to push your changes back to the Git repository.
Step 1: Installing TortoiseHg
Install the latest version from: http://bitbucket.org/tortoisehg/stable/wiki/download
This will install both TortoiseHg and command line Mercurial.
Step 2: Installing hg-git
Now that you have TortoiseHg installed, you will be using it to get the hg-git extension. For the sake of the tutorial, we will be using C:\hg-extensions as the extensions directory.
- Create the directory "C:\hg-extensions" using Windows Explorer
- Right click on the hg-exensions folder and select "TortoiseHg... \ Clone A Repository"
- Enter the source "http://bitbucket.org/durin42/hg-git/" and destination "C:\hg-extensions\hg-git"
- Click Clone
- Once its done click "Close" then "Cancel" (You will probably try to reclone the repository at least once by clicking "Clone" instead of "Cancel")
You should now have an hg working copy in "C:\hg-extensions\hg-git"
Unfortunately, there is an additional step. You must first obtain a copy of Dulwitch version 0.4.0 or later. You should download it from here: http://samba.org/~jelmer/dulwich/
For simplicity we will be placing it in C:\hg-extensions\dulwich-0.4.0, so you should extract it there. If you have extracted it correctly, then the following path should be valid "C:\hg-extensions\dulwich-0.4.0\dulwich".
Now, we have to hack hg-git a bit so it can find dulwich.
Open C:\hg-extensions\hg-git\hggit\__init__.py in a text editor.
Locate the following text at the top of the file:
Try hg clone git:// or hg clone git+ssh:// ''' from mercurial import commands, extensions, hg, util from mercurial.i18n import _
and add the 2 lines as shown
Try hg clone git:// or hg clone git+ssh://
'''
import sys
sys.path.append('C:\\hg-extensions\\dulwich-0.4.0')
from mercurial import commands, extensions, hg, util
from mercurial.i18n import _
Step 3: Configuring Mercurial to Use hg-git
- Right click anywhere, and select "TortoiseHg... \ Global Settings"
- In the dialog that comes up click "Edit File" (This should open up a text editor with "mercurial.ini")
- You should add the following to the file:
[extensions] hggit=c:\hg-extensions\hg-git\hggit hgext.bookmarks =
(Note: if there is already an [extensions] section, you should just add to it, dont declare a second one)
Now, we need to test and make sure hg-git is working. For this we use the command prompt. Go to a command prompt and use the following command:
hg help hggit
If you get help text for "hg-git Push and Pull From a Git Server" you are in business.
Step 4: Importing an Git Repository
At this point - we're going to assume that you have learned a little about how TortoiseHg (or just hg) works, and understand how to use it with a remote Hg repository. Working with a remote Git repository is essentially the same (with hg-git):
Here is an example using Collectinator's repository:
Just like before, you use "TortoiseHg... \ Clone a repository" from the right click menu.
This time you point to the git repository as the source: git://git.wowace.com/wow/collectinator/mainline.git
Note: hggit will use the end of the path before .git as the directory name.
You can use C:\collectinator or whatever you want as the destination, then click clone.
Once this is compete - you will have an Hg working copy in C:\collectinator\mainline and be able to both pull from and push to the Git repository using TortoiseHg.
It would probably be useful to read the hg-git documentation to learn how to use it in more detail.
Facts
- Date created
- 19 Oct 2009
- Last updated
- 21 Oct 2009