{"id":19954,"date":"2015-05-25T15:46:31","date_gmt":"2015-05-25T10:16:31","guid":{"rendered":"https:\/\/tothenewco.pro\/blog\/?p=19954"},"modified":"2016-12-19T15:07:34","modified_gmt":"2016-12-19T09:37:34","slug":"migrating-code-base-from-svn-to-git","status":"publish","type":"post","link":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/","title":{"rendered":"Migrating Code Base from SVN to GIT"},"content":{"rendered":"<p>Hi all,<\/p>\n<p>I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers.<\/p>\n<p>For migration I have used an utility tool <strong>git-svn<\/strong>.<\/p>\n<p>In order to install <strong>git-svn<\/strong> we can use below command in linux box :<\/p>\n<pre>\r\n\r\nsudo apt-get install git-svn\r\n\r\n<\/pre>\n<p>After that you can follow the steps mentioned below to migrate your code base.<\/p>\n<p>1. Create a text file(users.txt) that list all of the users those would appear in your SVN repository and then we need to map them in the following format &#8216;svn-username = Real Name &#8216; for Git.<\/p>\n<p>For Example:<\/p>\n<p>madhav-khanna = Madhav Khanna &lt;madhav@example.com&gt;<br \/>\ngaurav-sharma = Gaurav sharma &lt;gaurav@example.com&gt;<br \/>\namit-jain = Amit Jain &lt;amit@example.com&gt;<\/p>\n<p>We can get the list of all the svn-username by runing the following command<\/p>\n<pre>\r\n\r\nsvn log --xml | grep author | sort -u | perl -pe 's\/.*&gt;(.*?)&lt;.*\/$1 = \/&#039;\r\n\r\n<\/pre>\n<p>Now, after we get the list of all the users, we just need to map them in above prescribed format.<\/p>\n<p>2. Clone the svn repository using following command (git svn clone)<\/p>\n<pre>\r\n\r\ngit svn clone  --authors-file=users.txt --no-metadata -s my_project\r\n\r\n<\/pre>\n<p>By running the above command it will create a new Git repository of our project and we also need to provide our users.txt file in there to remap our users. This conversion can take some time. In my case it has taken 5 hours to clone it.<\/p>\n<p>Note: The &#8211;no-metadata flag tells git to ignore all the SVN junk except the actual commit log.<\/p>\n<p>3. Cleaning up the repository. If you had tags in the SVN repository, these are now remote branches for each tag. To display these tags you need to exceute the following command<\/p>\n<pre>\r\n\r\n$ cd \/path\/to\/repo\r\n\r\ngit branch -r\r\n\r\n<\/pre>\n<p>For each tag you need to exceute the following command<\/p>\n<pre>\r\n\r\ngit tag tagname tags\/tagname\r\n\r\ngit branch -r -d tags\/tagname\r\n\r\n<\/pre>\n<p>4. After that we just need to add our git origin using following command<\/p>\n<pre>\r\n\r\ngit remote add origin git@my-git-server:myrepository.git\r\n\r\n<\/pre>\n<p>5. Then we just need push our all branches using following command<\/p>\n<pre>\r\n\r\ngit push origin --all\r\n\r\n<\/pre>\n<p>So,by using <strong>git-svn<\/strong> tool we can easily migrate our code base form SVN to Git.<\/p>\n<p>Hope this helps !! \ud83d\ude42 \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After [&hellip;]<\/p>\n","protected":false},"author":96,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[7,446,1],"tags":[375,1793,1792],"class_list":["post-19954","post","type-post","status-publish","format-standard","hentry","category-grails","category-java","category-technology","tag-git","tag-migrate-svn-to-git","tag-svn"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"madhav.khanna\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Migrating Code Base from SVN to GIT | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Migrating Code Base from SVN to GIT | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#article\",\"name\":\"Migrating Code Base from SVN to GIT | TO THE NEW Blog\",\"headline\":\"Migrating Code Base from SVN to GIT\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/madhav-khanna\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2015-05-25T15:46:31+05:30\",\"dateModified\":\"2016-12-19T15:07:34+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#webpage\"},\"articleSection\":\"Grails, Java\\\/JVM, Technology, git, Migrate SVN to Git, SVN\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#listItem\",\"name\":\"Migrating Code Base from SVN to GIT\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#listItem\",\"position\":3,\"name\":\"Migrating Code Base from SVN to GIT\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/madhav-khanna\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/madhav-khanna\\\/\",\"name\":\"madhav.khanna\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/197362330e9b8015375fa21dfe3356a635edc1dfb367028c4414d92b857b9f68?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"madhav.khanna\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/\",\"name\":\"Migrating Code Base from SVN to GIT | TO THE NEW Blog\",\"description\":\"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/migrating-code-base-from-svn-to-git\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/madhav-khanna\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/madhav-khanna\\\/#author\"},\"datePublished\":\"2015-05-25T15:46:31+05:30\",\"dateModified\":\"2016-12-19T15:07:34+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Migrating Code Base from SVN to GIT | TO THE NEW Blog","description":"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After","canonical_url":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#article","name":"Migrating Code Base from SVN to GIT | TO THE NEW Blog","headline":"Migrating Code Base from SVN to GIT","author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/madhav-khanna\/#author"},"publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"},"datePublished":"2015-05-25T15:46:31+05:30","dateModified":"2016-12-19T15:07:34+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#webpage"},"isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#webpage"},"articleSection":"Grails, Java\/JVM, Technology, git, Migrate SVN to Git, SVN"},{"@type":"BreadcrumbList","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/tothenewco.pro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/tothenewco.pro\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#listItem","name":"Migrating Code Base from SVN to GIT"},"previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#listItem","position":3,"name":"Migrating Code Base from SVN to GIT","previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/tothenewco.pro\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/tothenewco.pro\/blog\/"},{"@type":"Person","@id":"https:\/\/tothenewco.pro\/blog\/author\/madhav-khanna\/#author","url":"https:\/\/tothenewco.pro\/blog\/author\/madhav-khanna\/","name":"madhav.khanna","image":{"@type":"ImageObject","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/197362330e9b8015375fa21dfe3356a635edc1dfb367028c4414d92b857b9f68?s=96&d=mm&r=g","width":96,"height":96,"caption":"madhav.khanna"}},{"@type":"WebPage","@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#webpage","url":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/","name":"Migrating Code Base from SVN to GIT | TO THE NEW Blog","description":"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/#breadcrumblist"},"author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/madhav-khanna\/#author"},"creator":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/madhav-khanna\/#author"},"datePublished":"2015-05-25T15:46:31+05:30","dateModified":"2016-12-19T15:07:34+05:30"},{"@type":"WebSite","@id":"https:\/\/tothenewco.pro\/blog\/#website","url":"https:\/\/tothenewco.pro\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Migrating Code Base from SVN to GIT | TO THE NEW Blog","og:description":"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After","og:url":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/","og:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Migrating Code Base from SVN to GIT | TO THE NEW Blog","twitter:description":"Hi all, I have a use case where I need to migrate the code base from svn to git while preserving all the commits of different committers. For migration I have used an utility tool git-svn. In order to install git-svn we can use below command in linux box : sudo apt-get install git-svn After","twitter:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"19954","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 23:28:28","updated":"2024-02-29 09:33:28","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tMigrating Code Base from SVN to GIT\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/tothenewco.pro\/blog"},{"label":"Technology","link":"https:\/\/tothenewco.pro\/blog\/category\/technology\/"},{"label":"Migrating Code Base from SVN to GIT","link":"https:\/\/tothenewco.pro\/blog\/migrating-code-base-from-svn-to-git\/"}],"_links":{"self":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/19954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/users\/96"}],"replies":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/comments?post=19954"}],"version-history":[{"count":0,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/19954\/revisions"}],"wp:attachment":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/media?parent=19954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/categories?post=19954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/tags?post=19954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}