This is the Hg-Git plugin for Mercurial, adding the ability to push to and pull from a Git server repository from Mercurial. This means you can collaborate on Git based projects from Mercurial, or use a Git server as a collaboration point for a team with developers using both Git and Mercurial.
The Hg-Git plugin can convert commits/changesets losslessly from one system to another, so you can push via a Mercurial repository and another Mercurial client can pull it. In theory, the changeset IDs should not change, although this may not hold true for complex histories.
You can clone a Git repository from Mercurial by
hg clone [url]. It will create a
directory with the same name as the last path component. For
example, if you were to run
git://github.com/schacon/munger.git it would clone
the repository down into the directory 'munger.git', then
convert it to a Mercurial repository for you.
hg clone git://github.com/schacon/munger.git
If you are starting from an existing Mercurial repository,
you have to setup a Git repository somewhere that you have
push access to, and then run
hg push [path]
from within your project. For example:
$ cd hg-git # (a Mercurial repository) $ hg bookmark -r default master # make a bookmark of master for default, so a ref gets created $ hg push git+ssh://firstname.lastname@example.org/schacon/hg-git.git $ hg push
This will convert all our Mercurial data into Git objects
and push them up to the Git server. You can also put that
path in the
[paths] section of .hg/hgrc and
then push to it by name.
Now that you have a Mercurial repository that can push/pull
to/from a Git repository, you can get updates
$ hg pull
That will pull down any commits that have been pushed to the server in the meantime and give you a new head that you can merge in.
First, make sure that you have a working C compiler on your
system. On Windows, one option is the
Visual C++. (Be sure to install the 2008 version for
compatibility reasons.) On Debian-style Linux,
apt-get install python-dev.
easy_install hg-git. If you don't
have easy_install available, you can get it as part of
Lastly, make sure the
following is in your
[extensions] hgext.bookmarks = hggit =
...and that's it!
Use this method if you'd like to install a clone of the Hg-Git repository rather than a static package, or if you'd like to install Hg-Git in a location you choose yourself.
First, install version 0.8.0 or newer of
You can do
easy_install 'dulwich>=0.8.0' if you have
installed. Next, clone
somewhere. Lastly, make the 'extensions' section in your
~/.hgrc' file look something like this:
[extensions] hgext.bookmarks = hggit = [path-to]/hg-git/hggit
That will enable the Hg-Git extension for you. The bookmarks section is only required prior to hg 1.7. Bookmarks will be translated to git heads when pushing.
Different versions of hg-git are known to work with different versions of Mercurial. For the most accurate info, go to the source on bitbucket, click the dropdown menu that says "default", click the "Tags" tab, select the version you've installed, and click on the file "Makefile". There's a line that starts with "all-version-tests" which lists the versions of Mercurial known to work.
It also needs Dulwich version 0.8.0 or later; Dulwich is a pure-Python implementation of the Git file formats and protocols. There are no Git binary dependencies: you do not need to have Git installed on your system.