Just use Felipe Contreras' mercurial bridge. GIT repo here.
End of story.
I worked the crap below out after scouring a whole load of tutorials I found on the web. After having some issues getting them to work, the very helpful #mercurial IRC channel informed me everything I'd wasted my time trying to learn was horrifically out of date.
The internet can be a good source of information, but a worse source of misinformation.
Now I can't say I ever liked Mercurial, but if your user interface changes radically every couple of years, then *you're doing coding wrong*. One stupid idea stuck in their skulls - 'no rewriting of history' - and they let that get in the way of everything else, introducing a whole bunch of broken misfeatures to support their wrong-think. Then in the space of a few years, about a dozen ways were created to work around their idiotic obsession. All of these ways are incompatible. All of these ways became fashionable, and within a year drop out of popularity, and become obselete. It's basically scorched earth. And it's a fuck-up.
I will say that the 15th method of letting you locally rewrite history is actually pretty well thought out, but the fact that there have been 14 fuckups before it means that my prejudice against Mercurial is reinforced, not relieved. No. I'm not going to tell you what the well-thought-out method is. As I couldn't bear to be part of the problem when the 16th method comes along and obsoletes the 15th method. Just use git.
Anyway, purely for reference, this is what I wasted my time on: Fuck you very much, Mercurial.
This is almost entirely based on Chris Adams' "How to work in Git and push changes to Mercurial using hg-git" tutorial, which in turn is based on Travis Cline's "Using hg-git to work in git and push to hg" blog post. I've fixed a couple of errors, and updated it with a few stylistic tweaks based on the assumption that if you're trying to avoid using Hg on one project, then you'll always want to avoid using Hg (and also that you use Debian). My changes are (highlighted thus).
# aptitude install mercurial-git
[extensions] git =
[git] intree = 1(I am presuming your hg is modern enough to have the 'bookmark' facility as an always-enabled builtin.)
$ hg clone http://hg.dovecot.org/dovecot-2.2
$ cd dovecot-2.2
$ hg bookmark hg/default -r default
$ hg gexport(this takes a surprisingly long time.)
$ git init
[ui] ignore = ~/.hgignore
$ echo ".git" >> ~/.hgignore
$ git config --global core.excludesfile ~/.gitignoreor by adding editting ~/.gitrc manually, adding:
[core] excludesfile = ~/.gitignore
echo ".hg*" >> ~/.gitignore
$ git config core.excludesfile `pwd`/.hg/hgignore
$ git branch --track master hg/default $ git reset --hard
$ hg gimport
$ hg push