Monthly Archives: February 2012

Getting stuff from git to hg

You’ve got a git commit. You want to turn it into an hg mq patch.

mq doesn’t understand git commit headers, even if it does understand the git diff format.

git show to the rescue! Simply ensure that the following is in your ~/.gitconfig:

hgshow = "show -U8 --pretty="format:# HG changeset patch%n# User %an <%ae>%n%s%n""

Now you can run git show HEAD (or another commit of your choice) to have it print in a format that you can directly pipe into hg qimport. Automate this with some sed (and see the -R argument to hg, for example) and you can put together some scripts to land code from one repo to another.