importing from hg to git

Had to import a repository from Mercurial to Git today.

I used fast-export:

git clone git://repo.or.cz/fast-export.git

Because the author fields were an utter mess, I needed to create an authors map. This is not well documented but it’s of the form email address to author <email>. For example:

Administrator@MACHINE.localdomain=Bob McBadgers <bob@badgers.st>
badgerbob@gmail.com=Bob McBadgers <bob@badgers.st>
badgerbob@MyMachine=Bob McBadgers <bob@badgers.st>

You then create a new git repo, e.g.

mkdir myapp.git ; cd myapp.git
git init --bare --shared=group
../fast-export/hg-fast-export.sh -A ../authors.map -r ../myapp.hg/

If it produces an empty repo, ensure you have the Mercurial Python modules available.

Author: Danielle

Danielle is an Australian software engineer, computer scientist and feminist. She doesn't really work on GNOME any more (sadly). Opinions and writing are solely her own and so not represent her employer, the GNOME Foundation, or anyone else but herself.

Leave a Reply

Your email address will not be published. Required fields are marked *

Creative Commons Attribution-ShareAlike 2.5 Australia
This work by Danielle Madeley is licensed under a Creative Commons Attribution-ShareAlike 2.5 Australia.