Converting from hg to git

Recently I decided to switch from Mercurial to git as my home source control system. This is mostly because we’re moving towards git at work and I need to master it.

These are some very simple notes on the process I followed. This article was extremely helpful to me. Following those directions I was able to take an existing Mercurial repo and convert it to git, all the while preserving its commit history.

My setup has two places for sources, ~/source/hg and ~/source/git. The former is for my Mercurial repositories, the latter for git.

Here are the steps:

1. Create temporary git repo.

$ cd ~/source/git
$ git init --bare lemboscripts.git

2. Push your existing Mercurial repo into this new git repo.

$ cd ~/source/hg/lemboscripts
$ hg push ~/source/git/lemboscripts.git

3. Now clone to a fresh repository.

$ cd ~/source/git
$ git clone lemboscripts.git lemboscripts

4. Verify everything worked by doing a “git status” and then “git log” to see the history.

$ git log
commit 93280e90158e905886ee330c3025a2c124142b5f
Author: Phil Lembo <>
Date:   Sun May 18 10:03:27 2014 -0400

    Scripts used in installing & running Fedora 20 on the Acer C720.

commit 84488d3f41b9aff01e40b675cc8e71504f27614e
Author: Phil Lembo <>
Date:   Sat May 10 02:16:33 2014 -0400

    Remove width from <main> elements.
This entry was posted in Development, System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).