Git as mercurial client? Why no git-hg?

GitMercurialInterop

Git Problem Overview


This is a question that's been bothering me for a while. I've done my homework and checked stackoverflow and found at least these two topics about my question: Git for Mercurial like git-svn and Git interoperability with a Mercurial repository

I've done some serious googling to solve this issue, but so far with no luck. I've also read the Git Internals book, and the Mercurial Definitive Behind the Scenes to try to figure this out. I'm still a bit puzzled why I haven't been able to find any suitable git-hg type of a tool.

From my perspective git-svn is one of the main features, why I've chosen to use git over mercurial also at work. It allows me to use a workflow I like, and nobody else needs to bother, if they don't care. I just don't see the point in using the intermediate hg repo to convert back and forth, as suggested in one of the chains.

So anyway, from what I've read hg and git seem very similar in conceptual design. There are differences under the hood, but none of those should prevent creating a git client for hg. As it seems to me, remote tracking branches and octopus merges make git even more powerful than hg is.

So, the real question, is there any real reason why git-hg does not exist (or at least is very hard to find)? Is there some animosity from git users (and developers) towards their hg counterparts that has caused the lack of the git-hg tool? Do any of you have any plans to develop something like this, and go public with it? I could volunteer (although with very feeble C-skills) to participate to get this done. I just don't possess the full knowledge to start this up myself.

Could this be the tool to end all DVCS wars for good?

Git Solutions


Solution 1 - Git

I haven't tried this, but there seems to be a git-hg project. The project describes itself on the page and the README as:

> A git-hg utility for checking out and > tracking a mercurial repo. > > A set of > scripts for checking out and tracking > a mercrial [sic] project.

It doesn't seem to work bi-directionally though (see issue tracker).

Solution 2 - Git

There is another project to realize this: git-remote-hg. Actually two of them, a native one (see https://github.com/msysgit/msysgit/wiki/Guide-to-git-remote-hg) and another one based upon hg-git (see https://github.com/rfk/git-remote-hg). The former is much faster than the latter, but still incomplete and under development.

There are actually git remote helpers (as these tools are called) for other systems, either already there or under development; this includes support for Subversion, CVS, bazaar, and even MediaWiki.

Cloning a Mercurial repository via git then is simply done like this:

git clone hg::https://hg.example.com/some-mercurial-repo

UPDATE: By now there is a third one, also "native", namely the one by Felipe which he mentions in his answer here. This one looks like it soon might be part of the git 'contrib' dir: https://github.com/felipec/git-remote-hg It works without requiring patches to git itself, though some patches to git (under review now) can be applied to improve the overall user experience.

UPDATE 2: And now there is yet another contender, this one being under quite active development, and based on felipe's code: https://github.com/buchuki/gitifyhg -- it works quite well for me so far, but there are still some rough spots.

UPDATE 3: Both gitifyhg and Felipe's git-remote-hg are currently not actively maintained. For the time being, I made a form of Felipe's code with some fixes, including some to make it work with recent Mercurial versions. You can get it from https://github.com/fingolfin/git-remote-hg. Finally, therere is yet another recent contender, git-cinnabar, using a completly different approach internally (though if you don't care about that, using it is more or less the same as for the other git-remote-hg implementations). I have not yet tried it myself, but you can find it at https://github.com/glandium/git-cinnabar

Solution 3 - Git

hg-git and the author's Pycon presentation explaining his take on the situation.not sure if you came across these while googling but they answered my questions.

Solution 4 - Git

hg-git apparently can be used to work with git locally, with a remote mercurial repo: http://traviscline.com/blog/2010/04/27/using-hg-git-to-work-in-git-and-push-to-hg/

Don't miss the comments there too.

Solution 5 - Git

Somebody already mentioned two git-remote-hg's, but here's a new one:

Bridge support in git for mercurial and bazaar

It has more features and should work more reliably than the msysgit one, but most importantly; you don't need any dependencies or a custom git build. Just copy to your $PATH, and that's it.

It has extensive tests to check that the output is exactly the same as hg-git, so it should work at least as well.

Solution 6 - Git

There is a new project that accomplishes just that:

It does the two-way thing nicely integrated.

Solution 7 - Git

I think there really just isn't much incentive to create one. No one's going to be horribly crippled by having to use one over the other; they're both DVCS. Sure, everyone probably has their preference, but they'll generally just suck it up and use the other if they have to. I assume hg-git has come about because git is very widely used, while far fewer projects have adopted hg.

In constrast, if a project is using svn or cvs, anyone who's had a taste of DVCS is going to be hurting - and they'll want that git-svn/hg-svn utility. There are a lot of projects out there using cvs/svn still, so plenty of demand.

You're probably right that it'd be a useful thing to have, though, assuming one of the two doesn't slowly win out over the other (git really does have a much larger userbase, I believe).

You're also right that there are no big technical obstacles - hg-git is bidirectional, so clearly it's possible to map the information between the two.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKai InkinenView Question on Stackoverflow
Solution 1 - GitakaiholaView Answer on Stackoverflow
Solution 2 - GitMax HornView Answer on Stackoverflow
Solution 3 - GitTom WillisView Answer on Stackoverflow
Solution 4 - GitThomas BroyerView Answer on Stackoverflow
Solution 5 - GitFelipeCView Answer on Stackoverflow
Solution 6 - GitabourgetView Answer on Stackoverflow
Solution 7 - GitCascabelView Answer on Stackoverflow