<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Malaika Consultants</title>
	<atom:link href="https://malaikaconsultants.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://malaikaconsultants.com/</link>
	<description>ECOMMERCE DEVELOPMENT RE-IMAGINED</description>
	<lastBuildDate>Sat, 06 Mar 2021 12:44:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://malaikaconsultants.com/wp-content/uploads/2021/02/cropped-Malaika-Fav-32x32.png</url>
	<title>Malaika Consultants</title>
	<link>https://malaikaconsultants.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Migrate from SVN to GIT in 7 easy steps</title>
		<link>https://malaikaconsultants.com/2021/03/06/migrate-from-svn-to-git-in-7-easy-steps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=migrate-from-svn-to-git-in-7-easy-steps</link>
					<comments>https://malaikaconsultants.com/2021/03/06/migrate-from-svn-to-git-in-7-easy-steps/#respond</comments>
		
		<dc:creator><![CDATA[Swanand Mokashi]]></dc:creator>
		<pubDate>Sat, 06 Mar 2021 12:42:06 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[GIT]]></category>
		<category><![CDATA[Source Control]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[source control]]></category>
		<category><![CDATA[svn]]></category>
		<guid isPermaLink="false">https://malaikaconsultants.com/?p=534</guid>

					<description><![CDATA[<p>How to migrate from SVN to GIT in 7 easy steps.</p>
<p>The post <a href="https://malaikaconsultants.com/2021/03/06/migrate-from-svn-to-git-in-7-easy-steps/">Migrate from SVN to GIT in 7 easy steps</a> appeared first on <a href="https://malaikaconsultants.com">Malaika Consultants</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Are you stuck with Subversion (SVN) because of the commit history? Do you want to migrate to GIT and include all the history in the GIT repository? Read on ..</p>



<p>GIT is a fantastic source repository. It is extremely fast and very easy to maintain branches and manage the workflow. SVN was a pretty popular source control for a number of years but has fundamental flaws with the workflow making it. SVN is a centralized version control system. This means that Subversion allows you to store a record of the changes made to a project, but that history is stored on a central server. Unlike Git, which is distributed, you need to have constant access to an SVN repository to push changes. These changes are saved as the developer implements them. In addition, instead of having a copy of a project’s history on your local machine, you only have a copy of the code itself. In other words, to see how a project has evolved, you need to reference the central version of the codebase.</p>



<p>Since you are already reading this post, most likely you are already sold on GIT or are looking to migrate to GIT. We were in a similar situation last year. One of our code repository was on a hosted SVN server and we really wanted to move to GIT. However, the SVN repository had almost 10 years of commit history and we did not want to lose that history &#8211; which was the main resistance to moving to GIT. However, it is quite easy to migrate from SVN to GIT and retain all the commit history. We used the following steps:</p>



<p><span class="has-inline-color has-vivid-red-color">NOTE: Most of these steps should be possible using a Linux or Mac terminal. We did this from a Windows machine. If you are using Windows, I would highly recommend getting Windows Subsystem for Linux (WSL): <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" target="_blank" rel="noreferrer noopener">https://docs.microsoft.com/en-us/windows/wsl/install-win10</a></span></p>



<p><strong>Step 1: Check all changes into SVN</strong><br>Make sure everything is checked into the SVN repository. This would mean letting your team members know that they need to check in their changes too.</p>



<p><strong>Step 2: Checkout the repository from SVN</strong><br><code>mkdir /gitmigration</code><br><code>cd /gitmigration</code><br><code>svn co &lt;SVN repository url&gt;</code><br>Replace the &lt;SVN repository url&gt; with your hosted or local SVN repository. This will create a new folder and checkout the SVN repo into that folder</p>



<p><strong>Step 3: Get all the authors that have committed their changes to the SVN repository over the course of time</strong>:<br><code>svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" &lt;"$2"&gt;"}' | sort -u &gt; authors-transform.txt</code><br>This will get all the authors and add them to a new text file authors-transform.txt</p>



<p><strong>Step 4: Modify the authors&#8217; list</strong> <br>The authors-transform.txt will give you a list of the authors &#8211; however, SVN will only give you the author usernames. GIT user&#8217;s format is slightly different &#8211; GIT expects the authors as Author Name &lt;Email Address&gt; format. So open the authors-transform.txt in any text editor and change the author names<br>e.g. my authors-transform.txt had the following entries<br>smokashi<br>user1<br>user2<br>and I changed it to<br>smokashi = Swanand Mokashi &lt;smokashi@malaikaconsultants.com&gt;<br>user1 = Developer One &lt;user1@malaikaconsultants.com&gt;<br>user2 = Developer Two &lt;user2@malaikaconsultants.com&gt;</p>



<p><strong>Step 5 : Let&#8217;s migrate</strong><br><code>mkdir /gitFolder<br>cd .. <br>git svn clone <strong>&lt;SVN REPO URL&gt;</strong> -T. --authors-file=gitmigration/authors-transform.txt --no-metadata --prefix "" gitFolder</code><br>Replace the <strong>&lt;SVN REPO URL&gt;</strong> with your SVN repository URL. At this point, you will have your git repository ready in the /gitFolder folder</p>



<p>Check if the history was migrated to GIT:<br><code>git log -n 3 --pretty=format:"%h - %an %ae %ar : %s"</code><br>This will give you a list of the last 3 commits, and you can see if the authors are correct for those commits<br><br><strong>Step 6 : Branches</strong><br>If you have any branches in SVN, we can move those over as well:<br><code>for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do git tag ${t/tags\//} $t &amp;&amp; git branch -D -r $t; done<br>for b in $(git for-each-ref --format='%(refname:short)' refs/remotes); do git branch $b refs/remotes/$b &amp;&amp; git branch -D -r $b; done<br>for p in $(git for-each-ref --format='%(refname:short)' | grep @); do git branch -D $p; done<br>git branch -d trunk</code></p>



<p><strong>Step 7: Commit to GIT repository</strong><br>Assuming you already have created a remote GIT repository on the host of your choice: GitHub, GitLab, Amazon CodeCommit, or Azure. Get the repo clone URL<br><code>git remote add origin '<strong>&lt;GIT repo clone url&gt;</strong>'<br>git push origin --all</code><br>Replace <strong>&lt;GIT repo clone URL&gt;</strong> with your GIT clone url.</p>



<p>And voila! you have migrated your SVN repository to GIT with all the history migrated as well.<br></p>



<p></p>



<p><br></p>



<p></p>



<p></p>
<p>The post <a href="https://malaikaconsultants.com/2021/03/06/migrate-from-svn-to-git-in-7-easy-steps/">Migrate from SVN to GIT in 7 easy steps</a> appeared first on <a href="https://malaikaconsultants.com">Malaika Consultants</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://malaikaconsultants.com/2021/03/06/migrate-from-svn-to-git-in-7-easy-steps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
