I use GIT on a Mac. Enough said. I have the tools, I have the experience. And I want to continue to use it. No wars here...
The problem is always with interoperability. Most people use SVN, which is great for me. Git SVN works out of the box, and is a no frills solution. People can continue happily use SVN and I don't lose my workflow and neither my tools.
Now... Some guys come along with Mercurial. Fine for them: they have their reasons. But I can't find any GIT HG out-of-the-box. I don't want to switch to HG, but I still need to interoperate with their repository.
Any of you guys know a simple solution for this?
Update from June 2012. Currently there seem to be the following methods for Git/Hg interoperability when the developer wants to work from the git side:
Install Mercurial and the hg-git extension. You can do the latter using your package manager, or with easy_install hg-git
. Then make sure the following is in your ~/.hgrc:
[extensions]
hggit =
You may see some references that talk about specifying the bookmarks
extension here too, but that has been built into Mercurial since v 1.8. Here are some tips about installing hg-git on Windows.
Once you have hg-git, you can use commands roughly like Abderrahim Kitouni posted above. This method has been refined and tweaked since 2009 though, and there is a friendly wrapper: git-hg-again. This uses the toplevel directory as a working directory for both Mercurial and Git at the same time. It creates a Mercurial bookmark that it keeps in synch with the tip of the default
(unnamed) branch in the Mercurial repository, and it updates a local Git branch from that bookmark.
git-remote-hg is a different wrapper, also based on the Mercurial hg-git
extension. This additionally makes use of the git-remote-helpers
protocols (hence its name). It uses the toplevel directory only for a Git working directory; it keeps its Mercurial repository bare. It also maintains a second bare Git repository to make synching between Git and Mercurial safer and more idiomatically gitlike.
The git-hg script (formerly maintained here) uses a different method, based on hg-fast-export
from the fast-export project. Like method 2, this also keeps a bare Mercurial repository and an additional bare Git repository.
For pulling, this tool ignores Mercurial bookmarks and instead imports every named Mercurial branch into a Git branch, and the default (unnamed) Mercurial branch into master.
Some commentary discusses this tool as being hg->git only, but it claims to have merged in git->hg push support on 7 Dec 2011. As I explain in a review of these tools, though, the way this tool tries to implement push support doesn't seem to be workable.
There's also another project called git-remote-hg. Unlike the version listed above, this one doesn't rely on hg-git, but instead directly accesses the Mercurial Python API. At the moment, using it also requires a patched version of git. I haven't tried this yet.
Finally, Tailor is a project that incrementally converts between a variety of different VCSs. It sounds like development of this won't be aggressively continued.
The first three of these approaches looked lightweight enough to persuade me to investigate. I needed to tweak them in some ways to get them to run on my setup, and I saw some ways to tweak them further to improve them, and then I tweaked them still further to make them behave more like each other so that I could evaluate them more effectively. Then I thought others might like to have these tweaks too, to do the same evaluation. So I've made a source package that will enable you to install my versions of any of the first three tools. It should also take care of installing the needed hg-fast-export
pieces. (You need to install hg-git
on your own.)
I encourage you to try them out and decide for yourself what works best. I'll be glad to hear about cases where these tools break. I'll try to keep them in synch with upstream changes, and to make sure the upstream authors are aware of the tweaks I think are useful.
As I mentioned above, in evaluating these tools, I came to the conclusion that git-hg
is only usable for pulling from Mercurial, not for pushing.
Relatedly, here are some useful comparisons/translation manuals between Git and Mercurial, in some cases targetted at users who already know Git: