Life Codecs @ NamingCrisis.net

Ruminations. Reflections. Refractions. Code.

Jul 8, 2012 - software dev

Converting from Mercurial to Git

This is basically augmenting (and repeating) this guide.

1
2
3
4
5
6
7
8
9
10
11
12
# get the hg-fast-export util
git clone git://repo.or.cz/fast-export.git

# create your git target repo, and cd into it.
git init git_migration_target_repo
cd git_migration_target_repo

# export the hg repo into (current git repo)
/path/to/hg-fast-export.sh -r /path/to/old/mercurial_repo

# don't forget to do this! or git status will show you a bunch of deletes
git checkout HEAD

Augments:

  • Under Debian, you can issue aptitude update && aptitude hg-fast-export, rather than cloning the repo, unless you want the latest and greatest I suppose.
  • My main use case was converting my bitbucket repo to git, I did the following:
    • bitbucket: renamed the mercurial repo (say call it “foo”) to foo-hg
    • bitbucket: created a git foo repo
    • local: git clone the empty foo bitbucket repo
    • local: perform the migration above into the cloned repo
    • local: push the cloned repo to bitbucket
    • bitbucket: trash foo-hg!