Tag Archives: Mimbolovehg-git

Howto set up git mirror of your mercurial repo

Written by elwood

This guide covers a process in Windows with TortoiseHG as mercurial client.

Install git, generate ssh keys

  • Install git
  • Sign up for github
  • Generate ssh keys and store it into ~/.ssh
  • Upload ssh keys to your github account
  • Create git repo

Install hg-git extension

  • Install python3 and set up PATH to python bin directory
  • Clone hg-git plugin source code
  • Add full path to hg-git source code to ~/mercurial.ini
    hggit = c:\Users\Igor\hg_plugins\hg-git\hggit

    Without trailing slash !

Configure mercurial’s putty to use git ssh key

  • Generate key pair file for putty (import existing keys and export as ppk)
    using puttygen tool
  • Add ssh key parameter to [ui] section of ~/mercurial.ini
    ssh=TortoisePlink.exe -i "c:\Users\Igor\.ssh\elwood.ppk"

Push changesets to it!

  • Run commands inside your hg repo:
    $ hg bookmark -r default master # make a bookmark of master for default, so a ref gets created
    $ hg push git+ssh://git@github.com:elw00d/consoleframework.git
  • If your mercurial commits are not recognized in github as yours, check the email of your git ssh key
    and email of committers. They should be equal to allow github detect that it was you.

Congratulations, you now have a mirror of your mercurial repo !

Support your mirror in actual state

If you have pulled some changesets from another hg repo, you may to want to push it to git. But your master bookmark needs to be “fast-forwarded”. To do this, use a command

$hg bookmark master

After that you can push to git repo again. Btw, usually if you run hg pull && hg update, bookmark will be updated automatically.