Using Open Source Tools Fast-export
Mercurial code base directory is/home/code_mercurial
The steps are as follows:
1. Download Fast-export
$git Clone Git://repo.or.cz/fast-export.git
Assuming the download is in the home directory, the directory structure is/home/fast-export
2. Create a new directory and initialize it to a git repository
$mkdir Code_git
$CD Code_git
$git Init
3. Convert using the Fast-export tool
Under the Code_git directory
$/home/fast-export/hg-fast-export.sh-r/home/code_mercurial
If you encounter error:repository have at least one unnamed head: ... Do the following two things:
1) Execute in code_mercurial directory
$HG bookmark-r default Master # make a bookmark of master for default, so a ref gets created
Then push and pull again.
2) If you still report an error, add the Force parameter, so
$/home/fast-export/hg-fast-export.sh-r/home/code_mercurial--force
4. In the Code_git directory execution
git reset HEAD
Get.