Converting a mercurial repo to git

Posted by Kenneth Kalmer on May 03, 2008

Keeping with the exodus from SVN/Mercurial to git, here is a super quick guide for converting a Mercurial repo to git.

1. Get the fast-export script via git

git clone git://repo.or.cz/fast-export.git

2. Make a new (empty) git repo for the project that is currently in Mercurial

git init projectname.git

3. Use fast-export to do the convertion

cd projectname.git
/path/to/fast-export.git/hg-fast-export.sh -r /path/to/project.hg
git checkout master

4. (Optionally) use rsync to bring over uncommitted changes

rsync -av --delete-after --exclude=.git --exclude=.hg /path/to/project.hg /path/to/project.git

5. Enjoy your new git repo :)

I’ve only followed these steps on projects that are in their infancy, and were used as Mercurial experiments. I’m not sure how well branches and tags will be handled by the script. Any feedback would be welcome.

  • Tags

    activerecord air amqp analytics audits bash bind capistrano cheat convert couchdb daemon-kit dlz dns elsewhere gentoo gist git hoptoad linux macros mercurial messaging mysql nginx olympics plugins postfix postini powerdns presentations projects quickies rails rake review ruby ruby19 ruote security shoes sitemap ssl svn webby
  • Recent Posts

  • Archives

  • Alltop. Seriously?! I got in?