05 Jan 2012

Migrate a repository from Mercurial to git

I’m using Linux more and more and I’m using git with my Linux projects. Now that I used both Mercurial and git, I feel more productive using git, basically for the branching. So I decided to move my Windows projects to git too, and get the same experience on both OS.

I’m hosting my projects on BitBucket as they offer free private repositories.

There’s a lot of blogs covering how to migrate a repos from Mercurial to git, I’m posting the method that worked for me as a reference.

On Linux:

git clone git://repo.or.cz/fast-export.git
mkdir new_git_repo
cd new_git_repo
git init
/path/to/hg-fast-export.sh -r /path/to/hg_repo
git add remote origin git@bitbucket.org:USER/repository_name.git
git push origin master