- Homepage: http://hg-git.github.com/
- https://bitbucket.org/durin42/hg-git (primary)
- https://github.com/schacon/hg-git (mirror)
The Hg-Git plugin can convert commits/changesets losslessly from one system to another, so you can push via an Hg repository and another Hg client can pull it and their changeset node ids will be identical - Mercurial data does not get lost in translation. It is intended that Hg users may wish to use this to collaborate even if no Git users are involved in the project, and it may even provide some advantages if you're using Bookmarks (see below).
Dependencies
This plugin is implemented entirely in Python - there are no Git binary dependencies, you do not need to have Git installed on your system. The only dependencies are Mercurial and Dulwich. See the Makefile for information about which versions of Mercurial are known to work, and setup.py for which versions of Dulwich are required.Usage
You can clone a Git repository from Hg by runninghg clone <url> [dest]
. For
example, if you were to run$ hg clone git://github.com/schacon/hg-git.git
If you want to clone a github repository for later pushing (or any other repository you access via ssh), you need to convert the ssh url to a format with an explicit protocol prefix. For example, the git url with push access
git@github.com:schacon/hg-git.git
git+ssh://git@github.com/schacon/hg-git.git
Your clone command would thus look like this:
$ hg clone git+ssh://git@github.com/schacon/hg-git.git
hg push [name]
from within
your repository. For example:$ cd hg-git # (an Hg repository) $ # edit .hg/hgrc and add the target git url in the paths section $ hg push
Now that you have an Hg repository that can push/pull to/from a Git repository, you can fetch updates with
hg pull
.$ hg pull
Hg-Git can also be used to convert a Mercurial repository to Git. You can use a local repository or a remote repository accessed via SSH, HTTP or HTTPS. Use the following commands to convert the repository (it assumes you're running this in $HOME).
$ mkdir git-repo; cd git-repo; git init; cd .. $ cd hg-repo $ hg bookmarks hg $ hg push ../git-repo
$ cd git-repo $ git checkout -b master hg
from https://bitbucket.org/durin42/hg-git
https://bitbucket.org/Scotty/hg-git