Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 140e0f862a
Fetching contributors…

Cannot retrieve contributors at this time

212 lines (186 sloc) 7.991 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Hg-Git Mercurial Plugin</title>
<script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="js/thickbox-compressed.js"></script>
<script type="text/javascript" src=""></script>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="css/print.css" type="text/css" media="print">
<!--[if IE]>
<link rel="stylesheet" href="css/ie.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8"/>
<link rel="stylesheet" href="css/thickbox.css" type="text/css" media="screen"/>
<div class="container">
<h1 class="tbar"><small>the</small> Hg-Git <small>mercurial plugin</small></h1>
This is the Hg-Git plugin for Mercurial, adding the ability
to <strong>push to and pull from a Git server</strong>
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.
<div class='section'>
<div class="title">The Big Idea</div>
<img style="float:right; padding:10px;" height="120" src="images/server.png">
The Hg-Git plugin can <strong>convert commits/changesets
losslessly</strong> 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
<div class='section'>
<div class="title">Commands</div>
You can clone a Git repository from Mercurial by
running <code>hg clone [url]</code>. It will create a
directory with the same name as the last path component. For
example, if you were to run <code>hg clone
git://</code> it would clone
the repository down into the directory 'munger.git', then
convert it to a Mercurial repository for you.
<pre>hg clone git://</pre>
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 <code>hg push [path]</code>
from within your project. For example:
<pre>$ 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://
$ hg push</pre>
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 <code>[paths]</code> 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
with <code>hg pull</code>.
<pre>$ hg pull</pre>
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.
<div class='section'>
<div class="title">Installing</div>
<h3>Installing Hg-Git the easy way:</h3>
First, make sure that you have a working C compiler on your
system. On Windows, one option is the
free <a href="">Microsoft
Visual C++</a>. (Be sure to install the 2008 version for
compatibility reasons.) On Debian-style Linux,
run <code>apt-get install python-dev</code>.
Secondly, run <code>easy_install hg-git</code>. If you don't
have easy_install available, you can get it as part of
<a href="">setuptools</a>
Lastly, make sure the
following is in your <code>~/.hgrc</code>:
hgext.bookmarks =
hggit = </pre>
...and that's it!
<h3>Installing Hg-Git manually</h3>
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
<a href="">Dulwich</a>.
You can do
<code>easy_install 'dulwich>=0.8.0'</code> if you have
<a href="">setuptools</a>
installed. Next, clone
<a href="">the Hg-Git
somewhere. Lastly, make the 'extensions' section in your
'<code>~/.hgrc</code>' file look something like this:
hgext.bookmarks =
hggit = [path-to]/hg-git/hggit</pre>
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.
<div class='section'>
<div class="title">Dependencies</div>
This plugin is known to work on Mercurial 1.7, and is
basically functional (with a couple of bugs) against hg 1.8
and 1.9. 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 <strong>no Git binary
dependencies</strong>: you do not need to have Git installed
on your system.
<div class='section'>
<div class="title">Sources</div>
Source available via
<a href="">hg</a>
(canonical repo) or
<a href="">git</a> (mirror
of hg). Patches preferred via email to
the <a href="">hg-git
mailing list</a>.
<div class="span-21">
<div id="bottom">
This plugin was originally developed by the folks
at <a href="">GitHub</a>, and is currently
maintained by Augie Fackler.
<div id="footer" class="span-21">
<div class="info span-12">
<div class="links">
<a href="">Google Group</a>
<div class="fork span-7">
This website is <a href="">open source</a>.
Please help us by forking the project and adding to it.
<script type="text/javascript">
$(function() {
Jump to Line
Something went wrong with that request. Please try again.