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
Here is a simple example of how to export your local clone of a Mercurial repo to GitHub.
First, add the hggit
extension to your ~/.hgrc
file if you have not already done so:
[extensions]
hggit =
Then run the following commands from the root of your Mercurial repository:
hg bookmark -r default master
hg push -f git+ssh://git@github.com/bolinfest/plovr.git
Personally, I had to specify -f
when running hg push
, though I suspect it is because I had some complicated branches in my Mercurial repo. You may not find it necessary for your migration.
Make sure that you have the git+ssh:
URI to your GitHub repo rather than the git:
URI. (The git+ssh:
URI is a bit harder to find in the new GitHub UI.)
Depending on the size of your repo, running hg push
may take awhile, so be patient. When you are done, you should be able to see your project on GitHub. In this example, my project was available at https://github.com/bolinfest/plovr.
As you would expect, now anyone can clone your public GitHub repo as follows:
git clone git@github.com:bolinfest/plovr.git
How to convert a Mercurial repo into a Git repo.
This is one of the most asinine sequences of events I have ever had to figure out, but I am not a Python guy at all.
(If you installed everything you should see it download and compile the Mercurial module)
I tried some of the other answers here and didn't have much luck. Here is the pretty straightforward method that what worked for me, after much trial and error:
First, download the hggit extension and add it to your ~/.hgrc or mercurial.ini file if you have not already done so:
[extensions]
hggit=\path\to\hg-git
For each branch you want to bring over to Git, add an Hg bookmark to the tip of the branch:
hg bookmarks hg-default
Then use hggit to create a git repo in the same folder as your current Hg repo by running hg gexport
. A .git folder will have been added as a result. When you then delete the .hg folder from your repo, you will be left with a local git repo.
If anyone is using Homebrew on OS X and wants to know the minor tweaks to get it to work properly please see the article here: http://www.ccannon.net/mercurial-to-git-conversion-with-homebrew.html
There doesn't seem to be any reason you can't run hg2git on windows. It's python which has a windows port. Just make sure the proper libraries are there and run it on the window box.
An easy way to convert between Git & Hg with no local process is to open a free KilnHg / Fogbugz account, create a private repo, push one format to it then pull in the other format, it works with both Git & Hg and (should) do seamless conversions.