Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Migrating to Git thanks to CloudBees

DZone's Guide to

Migrating to Git thanks to CloudBees

· Cloud Zone ·
Free Resource

Discover a centralized approach to monitor your virtual infrastructure, on-premise IT environment, and cloud infrastructure – all on a single platform.

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!

 

Learn how to auto-discover your containers and monitor their performance, capture Docker host and container metrics to allocate host resources, and provision containers.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}