Mercurial to Git

Mostly a note to myself as I forget it regularly.

The best way known to me to convert a Mercurial (hg) repo into a Git one is:

  1. get fast-export: git clone git://repo.or.cz/fast-export.git /tmp/fast-export
  2. create the new git repo and cd into it: git init new-repo; cd new-repo
  3. Import the hg repo: /tmp/fast-export/hg-fast-export.sh -r path-of-hg-repo
  4. Checkout master: git checkout master
  5. Optional: Convert your .hgignore to .gitignore. Mostly git mv .hgignore .gitignore and remove the syntax: glob from the top. If you’ve used regular expressions, you have to fix them by hand.