Search code examples
gitmercurial

Convert a Mercurial Repository to Git


I've already tried hg2git through fast-export and I've already tried hg-git.

Both with no success. hg2git actually worked, but I had to ask a friend who runs a Unix machine to do it. And that messed up all the linefeeds throughout the files.

hg-git simply failed with some libzip compression error.

Has anyone had any success converting a hg repo to git on Windows?

To be clear, I don't care about interop. I want to port the whole repo from hg to git, taking the history with me. I don't need to push changes back and forth - only convert once.


Solution

  • Did the following on my Mac to successfully export a Mercurial repo to Git (with full branches):

    mkdir myrepo; cd myrepo;
    git clone git://repo.or.cz/fast-export.git .
    rm -rf .git .gitignore
    git init
    ./hg-fast-export.sh -r ../path/to/local/hg/repo
    git clean -f # remove fast-export files