{ claus.conrad }

Converting Mercurial repositories to Git

📅 Sep 23, 2013
1 minute

How to convert Mercurial (hg) repos to Git, including all commits and history:

  1. Install Mercurial 1.7.5. Later versions may work, but that’s what I use.

  2. Install hg-git (a Mercurial extension). I’m not exactly sure what version I use, all I can say is that the version does matter, different hg-git versions work (or not) with different Mercurial versions. A link to more information about finding the right combination is at the bottom of the hg-git page.

  3. Install git (latest version is fine).

  4. Create a “bare” git repository, like this:

    git init --bare myrepo.git
  5. “Push” the hg repo to the git repo:

    hg push /path/to/myrepo.git
  6. If everything went well, you can now clone the Git repo to get your files back:

    git clone /path/to/myrepo.git myrepo