{"id":350,"date":"2016-11-27T19:23:38","date_gmt":"2016-11-27T23:23:38","guid":{"rendered":"http:\/\/www.mufljuz.com\/?p=350"},"modified":"2016-11-27T19:32:10","modified_gmt":"2016-11-27T23:32:10","slug":"migrating-svn-repository-to-git-preserving-history","status":"publish","type":"post","link":"https:\/\/www.mufljuz.com\/?p=350","title":{"rendered":"Migrating SVN repository to Git preserving history"},"content":{"rendered":"<p>After spending number of hours trying to move a simple single branch SVN repository to Git that can be accessed over https, here are the steps taken.<br \/>\nAssume <code>my_svn_repository<\/code> is defined by url <code>https:\/\/127.0.0.1\/svn\/my_svn_repository<\/code>.<\/p>\n<p>First, a list of all svn committers is needed. Save the list in  a file .\/authors.txt<\/p>\n<pre>\r\nuser1 = user1 &lt;user1@someserver.com&gt;\r\nuser2 = user2 &lt;user2@someserver2.com&gt;\r\n<\/pre>\n<p>Secondly, clone SVN repos<br \/>\n<code><br \/>\ncd ~\/tmp\/git\/<br \/>\ngit svn clone https:\/\/127.0.0.1\/svn\/my_svn_repository --authors-file=.\/authors.txt git_temp_repository<br \/>\n<\/code><\/p>\n<p>Thirdly, clean svn:ignore properties<br \/>\n<code><br \/>\ncd git_temp_repository<br \/>\ngit svn show-ignore > .gitignore<br \/>\ngit add .gitignore<br \/>\ngit commit -m 'Cleaning svn:ignore properties'<br \/>\n<\/code><\/p>\n<p>In the step four, clone temp repository to a bare git repos:<br \/>\n<code><br \/>\ngit clone --bare ~\/tmp\/git\/git_temp_repository my_git_repository.git<br \/>\n<\/code><\/p>\n<p>To setup nginx password protected server that serves only https, first install fcgiwrap<br \/>\n<code><br \/>\napt-get install fcgiwrap<br \/>\n<\/code><\/p>\n<p>and add config file:<br \/>\n<code><br \/>\nserver {<br \/>\n    listen 80;<br \/>\n    server_name git.myserver.com;<br \/>\n    return 301 https:\/\/$host$request_uri;<br \/>\n}<\/p>\n<p>server {<br \/>\n    listen       443 ssl;<br \/>\n    server_name  git.myserver.com;<\/p>\n<p>    ssl on;<\/p>\n<p>    ssl_certificate \/etc\/nginx\/ssl\/nginx.crt;<br \/>\n    ssl_certificate_key \/etc\/nginx\/ssl\/nginx.key;<\/p>\n<p>    access_log \/var\/log\/nginx\/git.access.log;<br \/>\n    error_log \/var\/log\/nginx\/git.error.log;<\/p>\n<p>    auth_basic \"Restricted\";<br \/>\n    auth_basic_user_file \/etc\/awstats\/.htpasswd;<\/p>\n<p>    location ~ \/git(\/.*) {<br \/>\n        fastcgi_pass  unix:\/var\/run\/fcgiwrap.socket;<br \/>\n        include \/etc\/nginx\/fastcgi_params;<br \/>\n        fastcgi_param SCRIPT_FILENAME   \/usr\/lib\/git-core\/git-http-backend;<br \/>\n        fastcgi_param GIT_HTTP_EXPORT_ALL \"\";<br \/>\n        fastcgi_param GIT_PROJECT_ROOT  \/home\/git\/tmp\/git;<br \/>\n        fastcgi_param PATH_INFO $1;<br \/>\n        fastcgi_param REMOTE_USER $remote_user;<br \/>\n  }<br \/>\n}<br \/>\n<\/code><\/p>\n<p>On client<br \/>\n<code><br \/>\ngit -c http.sslVerify=false clone https:\/\/sasa@git.myserver.com\/git\/my_git_repository.git<br \/>\n<\/code><br \/>\nhttp.sslVerify=false is used to allow self signed certificates during development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After spending number of hours trying to move a simple single branch SVN repository to Git that can be accessed over https, here are the steps taken. Assume my_svn_repository is defined by url https:\/\/127.0.0.1\/svn\/my_svn_repository. First, a list of all svn committers is needed. Save the list in a file .\/authors.txt user1 = user1 &lt;user1@someserver.com&gt; user2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/posts\/350"}],"collection":[{"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350"}],"version-history":[{"count":4,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"predecessor-version":[{"id":354,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions\/354"}],"wp:attachment":[{"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mufljuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}