gitversion-controlmercurialversion-control-migration

Migrating from Mercurial to Git


I know this question asked before several times and marked "possible duplicate", but none of them seems working correct. I tried fast-export and it gives error. Could anyone help How to migrate from Mercurial to Git? I need the history. It would be appreciated if it is listed step by step.

UPDATE:

I tried fast export:

cd ~
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo **[I get error in this line]**
git checkout HEAD

this gives error:

..... hg-fast-export.sh: line 79: python: command not found

Thanks for the help!


Solution

    1. Add hg-git to Mercurial
    2. Push hg-repo to git-target

    Step-by-step Guide

    A Clone Hg-Git Extension from it's repository into some local PATH\TO\HG-GIT

    B Enable extension in (global mercurial.ini or repository's-specific .hgrc)

    [extensions]
    bookmarks = 
    ...
    hggit = PATH\TO\HG-GIT
    

    bookmark was added long time ago, when this extension wasn't part of TortoiseHG|Mercurial, not sure about today's configuration

    C Create new Git-repository with read|write access to it (or remeber existing?!)

    D Add Git-repo from p. C into [paths] section of .hgrc for Mercurial repository, which you want to export in Git under any name. Sample for my local Mercurial repository, which have Git-mirror on Github

    [paths]
    default = git+ssh://git@github.com/lazybadger/Fiver-l10n.git
    

    E After it you can use Git-repository as usual remote repository in Mercurial and, as fist operation (for created empty Git-repository) you have to push to your new remote

    F Check existence of Git-repository with full history from Mercurial mirrored into it after push

    G Use Git-repository by usual way

    Sources, used in this guide

    Local repo in Workbench

    Mirror