Converting mercurial repositories to git
For the last little while I’ve stored meh in a mercurial repository I’ve hosted myself. Recently, I’ve wanted to move over to git and host it on github. Converting between the two turned out to be surprisingly simple using hg-git. Here’s what I did.
First I made a new empty git repository
Next I installed hg-git, a mercurial plugin which allows you to push and pull from git repositories. Once installed I ran this from the directory of my existing meh repository.
I was then able to push the new git repository to github without any trouble. You could also probably push directly to a remote github repository, skipping the intermediate local one.
I needed to slightly change the author details, to match that of my github account. Github provides an example of how to change author details in commit history. As I’m the sole author of meh, I was able to just use the following.