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 Uni
As of today, git distribution includes a tool to convert mercurial repositories to git, hg-to-git. If you have a recent git version installed, it is there. Worked very well for me.
If you're really only looking to do it this once you can use hg export
like this:
hg export 0:tip -o all-changesets-in-one.patch
or if git prefers only one patch per file you can create one per changeset like this:
hg export 0:tip -o changeset-%r.patch
presumably git apply
can take one or the other of those formats.
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
If you happen to be using GitHub and your Mercurial repo is available via HTTP/HTTPS...
In the course of using fast-import (a great tool, that converted my repo without issue) and pushing my new git repo from my dev box to GitHub, I noticed an option to "Import Code from Another Repository" during the "Quick Setup" portion of my git repo on GitHub.
I tested it out and achieved the same results as using fast-import. Using the GitHub import option turned out to be a bit easier in my case than fast-import (again, nothing against that tool, and no, I don't work for GitHub). The steps which worked for me were:
Have you tried tailor? It can pretty much convert anything to anything, as VCS go, and is even able to do it incrementally (that is, you convert once, then add new commits from the source to the target, without reconverting from scratch). You may not need it now, but it still is a nice feature.
Here are all the pieces put together for a migration on Windows.
Prerequisites
During install, allow binding to .sh files.
Ensure that all tools are available in the PATH environment variable.
Migration
mkdir c:\git_work
cd c:\git_work
git clone http://repo.or.cz/r/fast-export.git
Now you need mercurial libs for python. Either get them from here or do the following steps.
Edit c:\git_work\fast-export\hg-fast-export.py:
import sys # move this line up here
# Add a new line that imports [mercurial libraries][2] from this zip:
sys.path.append(r'C:\Program Files\TortoiseHg\library.zip')
# ...above the old line:
from mercurial import node
mkdir MyNewGitRepo
hg-fast-import.sh -r c:\Path\To\MyOldHgRepo
Remove the migration scripts:
git clean -n # see what would happen
git clean -f # delete migration files
Restore missing files by resetting the index and working tree.
git reset --hard