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

Deploy and scale data-rich applications in minutes and with ease. Mesosphere DC/OS includes everything you need to elastically run containerized apps and data services in production.

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!

 

Discover new technologies simplifying running containers and data services in production with this free eBook by O'Reilly. Courtesy of Mesosphere.

Topics:

Published at DZone with permission of Łukasz Budnik, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}