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.

About Danielle

Danielle is an Australian software engineer, computer scientist and feminist. She has worked on GNOME for some time now. Opinions and writing are solely her own and so not represent her employer, the GNOME Foundation, or anyone else but herself.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>