{"id":1043,"date":"2012-06-13T12:39:36","date_gmt":"2012-06-13T02:39:36","guid":{"rendered":"http:\/\/www.malcolmgroves.com\/blog\/?p=1043"},"modified":"2014-06-10T22:04:02","modified_gmt":"2014-06-10T12:04:02","slug":"migrating-svn-to-git-with-history","status":"publish","type":"post","link":"http:\/\/www.malcolmgroves.com\/blog\/?p=1043","title":{"rendered":"Migrating SVN to Git with history"},"content":{"rendered":"<p>I&#8217;ve been using Git more and more lately, mostly because it allows me to do lots of checkins locally, even when disconnected, and then push those centrally when I get back online.<\/p>\n<p>I&#8217;ve just gone through the process of migrating all my public and private SVN repositories to <a href=\"https:\/\/github.com\/malcolmgroves\" target=\"_blank\">github<\/a> (for the public ones) and <a href=\"https:\/\/bitbucket.org\/\" target=\"_blank\">BitBucket<\/a> (for the private ones). A one-way migration is not that difficult, but a one-way migration with all the checkin history, branches and tags proved to be a little more involved.<!--more--><\/p>\n<p>After a few false starts I found <a href=\"http:\/\/blokspeed.net\/blog\/2010\/09\/converting-from-subversion-to-git\/\" target=\"_blank\">this post<\/a>, which worked almost entirely, except for the section &#8220;Getting a bare repository onto the server&#8221;. The command:<\/p>\n<p><code>git clone --bare mscn_temp mscn.git<\/code><\/p>\n<p>(or the equivalent with my repository names substituted) produced something that I could not get bitbucket to recognise. This may be down to my relatively low git-fu, however eventually I dropped the .git on the end of the new repository name and then I could proceed.<\/p>\n<p>The second problem in that same section is where he says &#8220;Upload your bare repository to your server wherever you would like. Do this with the tool you are used to to upload stuff to your server.&#8221; Well, I&#8217;m not that used to uploading bare repositories, so I needed some help. Eventually, the BitBucket docs and StackOverflow came together to get me the following:<\/p>\n<p><code>git remote -v<\/code><\/p>\n<p>showed me that I still had a remote link called origin to my temporary git repository into which I&#8217;d imported the svn repository. I removed this with:<\/p>\n<p><code>git remote rm origin<\/code><\/p>\n<p>I could then add a new one pointing to the new, empty, bitbucket repository with:<\/p>\n<p><code>git remote add origin ssh:\/\/git@bitbucket.org\/username\/repositoryname<\/code><\/p>\n<p>(substituting in my username and repository name of course).<\/p>\n<p>This allowed me to finally push the master branch up to bitbucket with:<\/p>\n<p><code>git push -u origin master<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using Git more and more lately, mostly because it allows me to do lots of checkins locally, even when disconnected, and then push those centrally when I get back online. I&#8217;ve just gone through the process of migrating all my public and private SVN repositories to github (for the public ones) and BitBucket [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[48,75,70],"class_list":["post-1043","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-embarcadero","tag-git","tag-subversion"],"_links":{"self":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1043"}],"version-history":[{"count":7,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions"}],"predecessor-version":[{"id":1553,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions\/1553"}],"wp:attachment":[{"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.malcolmgroves.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}