{"id":1677,"date":"2011-11-21T17:29:50","date_gmt":"2011-11-21T21:29:50","guid":{"rendered":"http:\/\/fgiasson.com\/blog\/?p=1677"},"modified":"2012-05-23T08:41:43","modified_gmt":"2012-05-23T12:41:43","slug":"moving-projects-from-google-code-to-github","status":"publish","type":"post","link":"https:\/\/fgiasson.com\/blog\/index.php\/2011\/11\/21\/moving-projects-from-google-code-to-github\/","title":{"rendered":"Moving Projects from Google Code to GitHub"},"content":{"rendered":"<table>\n<tbody>\n<tr>\n<td>Last week we slowly migrated <a title=\"Structured Dynamics LLC.\" href=\"http:\/\/structureddynamics.com\">Structured Dynamics<\/a>&#8216; Google Code Projects to <a title=\"Structured Dynamics' Open Source Projects\" href=\"https:\/\/github.com\/structureddynamics\">GitHub<\/a>.We have been thinking about moving to GitHub for some time now, but we only wanted to move projects to it if no prior history and commits were dropped in the process. One motivation for the possible change has been the seeming lack of support by Google for certain long-standing services: we are seeing disturbing trends across a number of existing services. We also needed a migration process that would work with all of our various projects, without losing a trunk, branch, tag or commits (and their related comments).<\/td>\n<td><a href=\"https:\/\/github.com\/structureddynamics\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1713\" src=\"https:\/\/fgiasson.com\/blog\/wp-content\/uploads\/2011\/11\/github-profile-200x300.png\" alt=\"\" width=\"120\" height=\"180\" srcset=\"https:\/\/fgiasson.com\/blog\/wp-content\/uploads\/2011\/11\/github-profile-200x300.png 200w, https:\/\/fgiasson.com\/blog\/wp-content\/uploads\/2011\/11\/github-profile.png 300w\" sizes=\"auto, (max-width: 120px) 100vw, 120px\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It was not until recently that I found a workable process. Other people have successfully migrated Google Code SVN projects to GitHub, but I had yet to find a consolidated guide to do it. It is for this last reason that I write this blog post: to help people, if they desire, to move projects from Google Code to GitHub.<\/p>\n<h3>Moving from Google Code to GitHub<\/h3>\n<p>The protocol outlined below may appear complex, but it looks more intimidating than it really is. Moving a project takes about two to five minutes once your GitHub account and your migration computer is properly configured.<\/p>\n<p>You need four things to move a Google Code SVN project to GitHub:<\/p>\n<ol>\n<li>A Google Code project to move<\/li>\n<li>A GitHub user account<\/li>\n<li>SSH keys, and<\/li>\n<li>A <em>migration computer<\/em> that is configured to migrate the project from Google Code to GitHub. (in this tutorial, we will use a Ubuntu server; but any other Linux\/Windows\/Mac computer, properly configured, should do the job)<\/li>\n<\/ol>\n<h3>Create GitHub Account<\/h3>\n<p>If you don&#8217;t already own a GitHub account, the first step is to <a title=\"Create GitHub Account\" href=\"https:\/\/github.com\/signup\/free\">create one here<\/a>.<\/p>\n<h3>Create &amp; Configure SSH Keys<\/h3>\n<p>Once your account has been created, you have to create and setup the SSH keys that you will use to commit the code into the Git Repository on GitHub:<\/p>\n<ol>\n<li>Go to the <a title=\"GitHub SSH Keys Registration Page\" href=\"https:\/\/github.com\/account\/ssh\">SSH Keys Registration page of your account<\/a><\/li>\n<li>If you already have a key, then add it to this page, <a title=\"How to create SSH keys on Windows for GitHub\" href=\"http:\/\/help.github.com\/win-set-up-git\/\">otherwise read this manual to learn how to generate one<\/a><\/li>\n<\/ol>\n<h3>Configure Migration Server<\/h3>\n<p>The next step is to configure the computer that will be used to migrate the project. For this tutorial, I use a <em>Ubuntu server<\/em> to do the migration, but any Windows, Linux or Mac computer should do the job if properly configured.<\/p>\n<p>The first step is to install Git and Ruby on that computer:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] sudo apt-get install git-core git-svn ruby rubygems[\/cc]<\/p>\n<p>To perform the migration of a Google Code SVN project to GitHub, we are using a Ruby application called <code><a href=\"https:\/\/github.com\/nirvdrum\/svn2git\">svn2git<\/a><\/code> that is now developed by <a href=\"https:\/\/github.com\/nirvdrum\">Kevin Menard<\/a>. The next step is to install <code>svn2git<\/code> on that computer:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] sudo gem install svn2git &#8211;source\u00c2\u00a0http:\/\/gemcutter.org [\/cc]<\/p>\n<h3>Migrate Project<\/h3>\n<p>Before migrating your project, you have to link the Google Code committers to GitHub accounts. This is done by populating a simple text file that will be given as input to <code>svn2git<\/code>.<\/p>\n<p>Open the <code>authors.txt<\/code> file into a temporary folder:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] sudo vim \/tmp\/authors.txt[\/cc]<\/p>\n<p>Then, for each author, you have to add the mapping between their Google Code and GitHub accounts. If a Google Code committer does not exist on GitHub, then you should map it to your own GitHub account.<\/p>\n<p>[cc lang=&#8217;text&#8217; line_numbers=&#8217;true&#8217;]<br \/>\n[raw]<br \/>\n (no author) = Frederick Giasson <fred@f...com><br \/>\n fred@f&#8230;com = Frederick Giasson <fred@f...com><br \/>\n[\/raw]<br \/>\n[\/cc]<\/p>\n<p>The format of this <code>authors.txt<\/code> file is:<\/p>\n<p>[cc lang=&#8217;text&#8217; line_numbers=&#8217;true&#8217; ][raw] Google-Account-Username = Name-Of-Author-On-GitHub <Email-Of-Author-On-Github[\/raw][\/cc]\n\nTake note of the first Google Code committer <code>(no author)<\/code> mapping. This link is required for every <code>authors.txt<\/code> file. This placeholder is used to map the initial commit performed by the Google Code system. (When Google Code initializes a new project, it uses that username for creating the first commit of any project.)<\/p>\n<p>When you are done, save the file.<\/p>\n<p>Now that set up is complete, you are ready to migrate your project. First, let&#8217;s create the folder that will be used to checkout the SVN project on the server, and then to push it on GitHub.<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;]<br \/>\ncd \/tmp\/<br \/>\nmkdir myproject<br \/>\ncd myproject<br \/>\n[\/cc]<\/p>\n<p>In this tutorial, we have a normal migration scenario. However, your migration scenario may differ from this one. It is why I would suggest you check out the <a href=\"https:\/\/github.com\/nirvdrum\/svn2git\">different scenarios that are supported by <code>svn2git<\/code> document<\/a>. Change the following command accordingly. Let&#8217;s migrate the Google Code SVN Project into the local Git repository:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] \/var\/lib\/gems\/1.8\/bin\/svn2git http:\/\/myproject.googlecode.com\/svn &#8211;authors \/tmp\/authors.txt &#8211;verbose [\/cc]<\/p>\n<p>Make sure that no errors have been reported during the process. If it is the case, then refer to the <code>Possible Errors and Fixes<\/code> section below to troubleshoot your issue.<\/p>\n<p>The next step is to create a new GitHub repository where to migrate the SVN project. <a title=\"Create a new GitHub repository\" href=\"https:\/\/github.com\/repositories\/new\">Go to this GitHub page to create your new repository<\/a>. Then you have to configure Git to add a remote link, from the local Git repository you created on your migration computer, to this remote GitHub repository:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] git remote add origin git@github.com:you-github-username\/myproject.git[\/cc]<\/p>\n<p>Finally, let&#8217;s push the local Git repository master, branches and tags to GitHub. The first thing to push onto GitHub is the SVN&#8217;s trunk. It is done by running that command:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] git push -u origin master[\/cc]<\/p>\n<p>Then, if your project has multiple branches and tags, you can push them, one by one, using the same command. However, you will have to replace <code>master<\/code> by the name of that branch or tag. If you don&#8217;t know what is the exact name of these branches or tags, you can easily list all of them using this Git command:<\/p>\n<p>[cc lang=&#8217;bash&#8217; line_numbers=&#8217;true&#8217;] git show-ref[\/cc]<\/p>\n<p>Once you have progressed through all branches and tags, you are done. If you take a look at your GitHub project&#8217;s page, you should see that the trunk, branches, tags and commits are now properly imported into that project.<\/p>\n<h3>Possible Errors And Fixes<\/h3>\n<h4>Fatal Error: Not a valid object name<\/h4>\n<p>There are a few things that can go wrong while trying to migrate your project(s).<\/p>\n<p>One of the errors I experienced is a <code>\"fatal\"<\/code> error message <code>\"Not a valid object name\"<\/code>. <a href=\"https:\/\/github.com\/nirvdrum\/svn2git\/issues\/26\">To fix this<\/a>, we have to fix a line of code in <code>svn2git<\/code>. Open the <code>migration.rb<\/code> file. Check around the <code>line 227<\/code> for the method <code>fix_branches()<\/code>. Remove the first line of that method, and replace the second one by:<\/p>\n<p>[cc lang=&#8217;ruby&#8217; line_numbers=&#8217;true&#8217;][raw] svn_branches = @remote.find_all { |b| !@tags.include?(b) &#038;&#038; b.strip =~ %r{^svn\\\/} }[\/raw][\/cc]<\/p>\n<h4>Error: author not existing<\/h4>\n<p>While running the <code>svn2git<\/code> application, the process may finish prematurely. If you check the output, you may see that it can&#8217;t find the match for an author. What you will have to do is to add that author to your authors file and re-run <code>svn2git<\/code>. Otherwise you won&#8217;t be able to fully migrate the project.<\/p>\n<p>I&#8217;m not quite sure why these minor glitches occurred during my initial migrate, but with the simple fixes above you should be good to go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week we slowly migrated Structured Dynamics&#8216; Google Code Projects to GitHub.We have been thinking about moving to GitHub for some time now, but we only wanted to move projects to it if no prior history and commits were dropped in the process. One motivation for the possible change has been the seeming lack of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[156,159,154,155,157,66],"tags":[198,215,213,212,214,216],"class_list":["post-1677","post","type-post","status-publish","format-standard","hentry","category-iron","category-open-semantic-framework","category-osf-for-drupal","category-osf-web-services","category-osf-widgets","category-programming","tag-developer","tag-git","tag-github","tag-google-code","tag-source-control","tag-svn"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1677"}],"version-history":[{"count":59,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1677\/revisions"}],"predecessor-version":[{"id":1956,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1677\/revisions\/1956"}],"wp:attachment":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}