{"id":152,"date":"2010-08-07T10:56:45","date_gmt":"2010-08-07T08:56:45","guid":{"rendered":"http:\/\/www.ceh-photo.de\/blog\/?p=152"},"modified":"2010-08-07T11:31:54","modified_gmt":"2010-08-07T09:31:54","slug":"from-git-github-to-svn-googlecode","status":"publish","type":"post","link":"https:\/\/www.ceh-photo.de\/blog\/?p=152","title":{"rendered":"From Git (github) to svn (googlecode)"},"content":{"rendered":"<p>We decided to move bajos from github to googlecode at therefore I need to port our repo. The task import from git to svn could be done in this way:<\/p>\n<p>From \u00a0<a href=\"http:\/\/code.google.com\/p\/support\/wiki\/ImportingFromGit\">http:\/\/code.google.com\/p\/support\/wiki\/ImportingFromGit<\/a><\/p>\n<p>Most of this is copied from the google page, but they are writing about continuous mirroring, I want to show, that the same procedure is useful for a one time import!<\/p>\n<p>The Subversion repository must be nonempty. A new Google Code project contains one revision by default, but if you reset it, you should also create a first revision.<\/p>\n<p style=\"max-width: 65em;\">Naturally, your official source tree lives on some Git-capable server, which we denote by\u00a0<tt style=\"font-size: 13px;\">$GIT_REPO<\/tt>.\u00a0<a style=\"color: #0000cc;\" href=\"http:\/\/code.google.com\/hosting\/createProject\">http:\/\/code.google.com\/hosting\/createProject<\/a> creating a new Google Code project, initialize an intermediary repository and fetch the Git tree:<\/p>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\">\u00a0$ git svn clone <\/span><span style=\"color: #666600;\">--<\/span><span style=\"color: #000000;\">username you https<\/span><span style=\"color: #666600;\">:<\/span><span style=\"color: #880000;\">\/\/your-project.googlecode.com\/svn\/<\/span><\/pre>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\"> $ GIT_REPO=git@github.com:hwr-berlin\/bajos.git #example!!!\r\n\u00a0$ cd svn\r\n\u00a0$ git fetch $GIT_REPO<\/span><\/pre>\n<p style=\"max-width: 65em;\">Create a temporary branch for the fetched repository, and tag its head:<\/p>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\">\u00a0$ git branch tmp $<\/span><span style=\"color: #666600;\">(<\/span><span style=\"color: #000000;\">cut <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #000000;\">b<\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #006666;\">40<\/span><span style=\"color: #000000;\"> <\/span><span style=\"color: #666600;\">.<\/span><span style=\"color: #000000;\">git<\/span><span style=\"color: #666600;\">\/<\/span><span style=\"color: #000000;\">FETCH_HEAD<\/span><span style=\"color: #666600;\">)<\/span><span style=\"color: #000000;\">\r\n\u00a0$ git tag <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #000000;\">a <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #000000;\">m <\/span><span style=\"color: #008800;\">\"Last fetch\"<\/span><span style=\"color: #000000;\"> <\/span><span style=\"color: #000088;\">last<\/span><span style=\"color: #000000;\"> tmp<\/span><\/pre>\n<p style=\"max-width: 65em;\">Unfortunately, Git treats the initial commit specially, and in particular, cannot rebase it. Work around this as follows:<\/p>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\">\u00a0$ INIT_COMMIT<\/span><span style=\"color: #666600;\">=<\/span><span style=\"color: #000000;\">$<\/span><span style=\"color: #666600;\">(<\/span><span style=\"color: #000000;\">git log tmp <\/span><span style=\"color: #666600;\">--<\/span><span style=\"color: #000000;\">pretty<\/span><span style=\"color: #666600;\">=<\/span><span style=\"color: #000000;\">format<\/span><span style=\"color: #666600;\">:%<\/span><span style=\"color: #000000;\">H <\/span><span style=\"color: #666600;\">|<\/span><span style=\"color: #000000;\"> tail <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #006666;\">1<\/span><span style=\"color: #666600;\">)<\/span><span style=\"color: #000000;\">\r\n\u00a0$ git checkout $INIT_COMMIT <\/span><span style=\"color: #666600;\">.<\/span><span style=\"color: #000000;\">\r\n\u00a0$ git commit <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #000000;\">C $INIT_COMMIT<\/span><\/pre>\n<p style=\"max-width: 65em;\">Apply all the other commits to the temporary branch, and make it the new master branch:<\/p>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\">\u00a0$ git rebase master tmp # takes a while\r\n\u00a0$ git branch <\/span><span style=\"color: #666600;\">-<\/span><span style=\"color: #000000;\">M tmp master<\/span><\/pre>\n<p style=\"max-width: 65em;\">Lastly, commit the changes to Google Code:<\/p>\n<pre style=\"font-size: 12px; margin-left: 2em; border-left-width: 3px; border-left-style: solid; border-left-color: #cccccc; padding: 0,5em;\"><span style=\"color: #000000;\">\u00a0$ git svn dcommit # depending on your repo size it could be a run some hours<\/span><\/pre>\n<p>I had problems during the dcommit because of some bug on googlecode. My commit cancels at some point. If you have the same problems check:<\/p>\n<p><a href=\"http:\/\/blogs.gnome.org\/diegoe\/2009\/03\/18\/saving-your-neck-when-git-svn-dcommit-fails\/\">http:\/\/blogs.gnome.org\/diegoe\/2009\/03\/18\/saving-your-neck-when-git-svn-dcommit-fails\/<\/a><\/p>\n<p>or:<\/p>\n<p><a href=\"http:\/\/groups.google.com\/group\/google-code-hosting\/browse_thread\/thread\/e0a6597f7f4c7739?pli=1\">http:\/\/groups.google.com\/group\/google-code-hosting\/browse_thread\/thread\/e0a6597f7f4c7739?pli=1<\/a><\/p>\n<p>I need to do it several times.<\/p>\n<p>Important you need the last hash (HEAD) from your git repo!!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We decided to move bajos from github to googlecode at therefore I need to port our repo. The task import from git to svn could be done in this way: From \u00a0http:\/\/code.google.com\/p\/support\/wiki\/ImportingFromGit Most of this is copied from the google page, but they are writing about continuous mirroring, I want to show, that the same [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[52,53,54,55],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-it","tag-git","tag-github","tag-googlecode","tag-svn"],"_links":{"self":[{"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":8,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ceh-photo.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}