Search code examples
gitmercurialazure-devopsgit-for-windowsfastexport

migrate Hg to Git via "fast-export" in Windows


I have a project having mercurial HG code source management,and try to migrate it on a VSTS/Git platform.

I read that there is a tool for doing that, "fast-export"... So I tried but not did't achieve to do it working in Windows...

Say I have D:\MyProject containing the .hg directory and the project code files, I

  • downloaded the fast-export files in the "D:\fast-export-master" folder,
  • created a new directory D:\MyProject-git
  • launched in that D:\MyProject-git the git init command (a new .git directory appeared then);
  • now from the same D:\MyProject-git i did
    ..\fast-export-master\hg-fast-export.sh -r "D:\MyProject"

now strange things starts happening, a command line window appeared and disappeared so quickly I didn't understood what happened, so I relaunched the previous command in a hope to see the message... I should try tens of times until able to capture in the printscreen the command-line message, that says strange things:

which: no D:\fast-export-master\hg-fast-export.sh in (/c/Users/xxx/bin:mingw64/bin:/user/local/bin:/usr/bin:/bin/mingw64/bin:/usr/bin:/c/Users/xxx/bin:/c/ProgramData/Oracle/Java/javapath:/c/WINDOWS/system32 [...etc...etc...])

I wonder what is the problem and how to solve it...

EDIT:

Following the @max630 suggestion bellow, I reinstalled Python and update the PATH, so it's recognized in the command

> python
Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

opened the "GIT Bash" from the start menu then

cd "/D/MyProject-git"
../fast-export-master/hg-fast-export.sh -r "D:\MyProject" --force

that gave:

../fast-export-master/hg-fast-export.sh: line 175: python: command not found
C:\Program Files\Git\mingw64\libexec\git-core\git-fast-import.exe statistics:
---------------------------------------------------------------------
Objects allocated:       5000
...

enter image description here


Solution

  • I think your concern is that you imported the "hg-fast-export" into a directory that was not added to your environment variables, according to the error message "D:\fast-export-master\hg-fast-export.sh" was not found in the list of your environment variables, so try to add th following "D:\fast-export-master\"in your environment variables and then try again.

    If it does not work out yet, look at this article and follow step by step what was said:

    https://www.appveyor.com/blog/2014/02/23/converting-mercurial-repository-to-git-on-windows/

    The author has copied the directory "hg-fast-export" into the new directory git (without the .git of "hg-fast-export") and has also added hg, git and python to his environment variables.

    good luck