Alex Rivera | Logout

How can I convert a Mercurial repository to Git...in *Windows*?

Asked 2012-07-03T23:29:56.733
17

Possible Duplicate:
Converting a Mercurial (hg) repository to Git on Windows (7)

There's a Mercurial repository that I want to convert to Git, which is what we use at work. I have Mercurial (for Windows) installed, and I've already cloned the Hg repository locally. I'm stuck on trying to convert it.

Most of the pages I've found assume that I'm using Unix/Linux, and the most common recommendation, hg-fast-export, seems to work only in those OSes. I do have access to the Git Bash. I've gotten as far as this (line-wrapped for easier reading):

$ ~/codeingit/fast-export/hg-fast-export.sh -r
        ~/codeinmercurial/projectiwanttoconvert

In response, I get:

ImportError: No module named mercurial

I've read a number of web pages about this which, again, assume that I'm using Unix/Linux and that I have Mercurial installed for that.

Is there anyone who's successfully converted an Hg repository to Git on Windows, and can write a step-by-step guide to doing it?

Edit
Report

1 Answer

42

1) Install Cygwin or Bash on Windows 10

Cygwin

  • Run setup.exe
  • Select Install from Internet
  • In the Select Packages dialog box:
    • Click Install at the top of the tree (next to All) until it shows Default
    • Expand the Devel subtree: Install git (change from Skip to the version number)
    • In the Devel subtree: Install mercurial (change from Skip to the version number)
    • Install Python subtree (change from Default to Install)
    • Click Next
  • If prompted to resolve dependencies, click Next
  • Get a cup of coffee, watch your favorite movie, or take a long nap

After the Cygwin installation is complete, open a bash shell to run the commands indicated in the steps below. The shortcut to bash will be called Cygwin Terminal.

Windows 10

  • Install Bash on Windows 10
  • Get a cup of coffee
  • Open Bash and type the following:
    • sudo apt install git
    • sudo apt install mercurial

2) Install fast-export

Open terminal (bash shell) and install fast-export:

   https://github.com/frej/fast-export.git

3) Initialize new git repo and migrate mercurial repo

   mkdir new_git_repo
   cd new_git_
answered 2012-07-04T07:07:01.823

Your Answer