Updated version of the instructions in http://traviscline.com/blog/2010/04/27/using-hg-git-to-work-in-git-and-push-to-hg/ with a few tweaks
Install hg-git (e.g.
pip install hg-git)Make sure you've enabled the Hg bookmark extension in your
.hgrcAdd this to your .hgrc:
[git] intree=1 [extensions] hggit =
And also .hg/hgignore: http://mercurial.selenic.com/wiki/TipsAndTricks#Ignore_files_in_local_working_copy_only
Clone your Mercurial repo:
$ hg clone https://[email protected]/ned/coveragepy
Change into the repo:
$ cd coveragepy
Create a local bookmark tracking your Mercurial default branch - this is what will be exported to Git:
$ hg bookmark hg/default -r default
Export to the git repo:
$ hg gexport
Configure Hg to ignore the Git repo:
$ echo ".git" >> .hg/hgignore
Configure Git to ignore the Hg repo:
$ echo ".hg*" >> .git/info/exclude
Configure Git to ignore the same things as Mercurial:
$ git config core.excludesfile `pwd`/.hg/hgignore
Have your master branch track the exported Hg default branch:
$ git branch --track hg/default master $ git reset --hard
hg-git created a "bare" git repository, even with intree = 1. Change that in .git/config, replace bare = true by bare = false.
Do stuff in Git and make commits
Export your changes to Hg:
$ hg gimport
Push them out to the world:
$ hg push