Cloud Zone is brought to you in partnership with:

Łukasz works as a Technical Architect for an international IT company and is responsible for delivering applications written in Java EE, Spring, and .NET. He has been involved in many various projects ranging from online insurance systems, voice and video solutions, mobile systems (both native and HTML5-based), medical systems, and large system integration projects. Łukasz is an expert in distributed systems, SOA, and cloud. Łukasz holds PhD in Computer Science. Łukasz is a DZone MVB and is not an employee of DZone and has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

Migrating to Git thanks to CloudBees

06.26.2012
| 2235 views |
  • submit to reddit

I got a free account (FOSS account) on CloudBees.com for my open source project (Qualitas). I decided to use the Maven and Jenkins parts of the CloudBees (for now), but was quite dissapointed when I saw that CloudBees' Jenkins supported only Git and SVN. My project used Hg. I wasn't emotionally attached to Hg so I decided to migrate my Hg repository to Git. Thankfully Google Code gave my a hint to use hg-fast-export tool. See below how easy it is to migrate your Hg repository to Git.

Installing Git

OK, first you have to install Git on your machine (if you don't have it already). If you're on Linux with yum installed, execute the following command:

yum install git


Installing hg-fast-export

Just clone their repo (Git repo of course :) ):

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

There will some shell and some Python scripts in there. Names indicate what they do.

Migrating repositories

OK. So to migrate my Hg repo I had to execute the following commands (change names of directories and you should be fine):

cd /work/qualitas/repository/qualitas
hg pull # just to make sure there are no pending changes in master repository
cd ..
mkdir tmp-qualitas-git
cd tmp-qualitas-git
git init
/your-path-to/hg-fast-export.sh -r ../qualitas

See the log for any errors.

Now clone tmp-qualitas-git and verify if both repositories are the same:

git clone tmp-qualitas-git qualitas-git
diff --brief -r qualitas qualitas-git

You should see only the differences in all files which were added to .hgignore. If there are differences in other files then something went wrong... which thankfully was not my case :)

Last step was to move .hgignore and tags files.

Migrating tags

Hg stores tags in .hgtags file. hg-fast-export took care of that and if you execute:

git tag


you will see all original tags copied from the Hg repo.

Migrating .hgignore

Migrating .hgignore to .gitignore is just a matter of copying and renaming the file :)

Summary

That's all, childishly simple.

Cloudbees.com I'm comming!

 

Published at DZone with permission of Łukasz Budnik, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)