<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" 
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
	<channel>
<title>Stutsman Software Blog</title><link>http://www.stutsmansoft.com/index.html</link><description>Stutsman Software Blog</description><dc:language>en</dc:language><dc:creator>derek@stutsmansoft.com</dc:creator><dc:rights>Copyright 2011 Derek Stutsman</dc:rights><dc:date>2011-11-27T22:21:27-06:00</dc:date><admin:generatorAgent rdf:resource="http://www.realmacsoftware.com/" />
<admin:errorReportsTo rdf:resource="mailto:derek@stutsmansoft.com" /><sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
<sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
<lastBuildDate>Fri, 16 Dec 2011 13:50:24 -0600</lastBuildDate><item><title>How I Learned to Stop Worrying and Love Git</title><dc:creator>derek@stutsmansoft.com</dc:creator><category>Development</category><dc:date>2011-11-12T14:59:04-06:00</dc:date><link>http://www.stutsmansoft.com/blog/files/31cacc6fc13520ecd3b96b28fb47876a-3.html#unique-entry-id-3</link><guid isPermaLink="true">http://www.stutsmansoft.com/blog/files/31cacc6fc13520ecd3b96b28fb47876a-3.html#unique-entry-id-3</guid><content:encoded><![CDATA[<h1>Subversion Curmudgeon</h1>I&rsquo;m a big proponent of source control, and have been for almost as long as I&rsquo;ve been developing software.  In my Windows days I used Visual SourceSafe&hellip;and actually liked it.<br /><br />In 2008 when I went Windows-sober and dove into iOS full time, I embraced Subversion as the de-facto SCM system for the platform.<br /><br />I grew quite comfortable with it, and made sure to expose my fellow developers to it as well.  Subversion has performed admirably and I&rsquo;ve never been bitten by it.<br /><br />Around a year and a half ago, some of my more forward thinking developer friends starting advocating Git as a replacement, and encouraged me to eschew SVN.<br /><br />I was, to put it mildly, hesitant.  I&rsquo;ve been in the business for long enough to have a bit of healthy caution when new technologies come on the scene.  Don&rsquo;t get me wrong - I <strong>love</strong> new/shiny technology and play with everything I can.  But I&rsquo;m a bit slower to adopt when we&rsquo;re talking about mission critical workflow tools.  <br /><br />I need a <strong>really</strong> good reason to fix something that&rsquo;s not broken.<br /><br />And so, I resisted.  As time progressed, I ended up the lone SVN holdout in my circle of developer buddies&hellip;and that concerned me.<br /><br />Was I being too cautious?  I didn&rsquo;t want to be &ldquo;that guy&rdquo; - the sad old developer who clings to ancient technology because it&rsquo;s what he knows, while the rest of the world marches forward.  <br /><br />Once I had a safe point in my release workflow to do so, I converted some of my SVN repos to Git and started experimenting.  Once I got over the initial learning curve problems, I found that I fell in love with it.  <br /><br />Since I held out for so long against Git, I now feel honor-bound to do my part proselytizing it.  <br />The purpose of this blog entry is to give people some real-world benefits to making the switch, and to pull together links on how to make the migration.<h1>Why Migrate?  Real-World Benefits of Git</h1>Before I switched, the main arguments people used to try and sell me on Git were:<br /><ul class="disc"><li>It&rsquo;s distributed.  I can check in code without being online.</li><li>It has really great branching.</li></ul>Neither of these made an impact on me.  I considered the &ldquo;distributed&rdquo; nature to be a detriment rather than a benefit, given my desire for a centrally located, backed-up repository. <br /><br />The branching benefit didn&rsquo;t sell me either, as I&rsquo;ve found branching to be an activity that is best done sparingly, and with large quantities of pain.<br /><br />Now that I <em>have</em> switched, I offer some real-world benefits that would have helped me get over the hump sooner.<h2>Real Branches and Tags</h2>Most SVN repos have a root-level structure like this:<br /><br /><span style="font:12px Courier, mono; ">	/branches<br />	/tags<br />	/trunk</span><br /><br />&ldquo;Trunk&rdquo; is the latest and greatest, &ldquo;tags&rdquo; holds a copy for each released version, and &ldquo;branches&rdquo; is used to store experiments until they get merged back into the trunk.<br /><br />The problem is, this folder structure is not enforced by Subversion - it&rsquo;s just 3 folders of files as far as SVN is concerned.  They could just as well be called &ldquo;foo&rdquo; &ldquo;bar&rdquo; and &ldquo;stuff.&rdquo;  <br /><br />Because SVN doesn&rsquo;t know the meaning of these folders, it doesn&rsquo;t treat them any differently.<br /><br />&ldquo;So what?&rdquo; you say.  &ldquo;I know what they are for and I&rsquo;m using them correctly.&rdquo;  <br />Maybe so, but let&rsquo;s assume a long-lived SVN project like this:<br /><br /><span style="font:12px Courier, mono; ">	/branches<br />		&nbsp;/newversion_testcode<br />	/tags<br />		&nbsp;/version_1.0<br />		&nbsp;/version_1.1<br />		&nbsp;/version_1.2<br />		&nbsp;/version_1.3<br />		&nbsp;/version_1.4<br />	/trunk</span><br /><br />When you pull this down from your SVN repository, it&rsquo;s going to run for a good long while&hellip;and you&rsquo;re going to end up with 7 full copies of the project on your disk.  &ldquo;So, what, disk is cheap&rdquo; may be a valid argument, but when you consider most people are moving to small+fast SSDs, space becomes precious again.<br /><blockquote><p>Git treats branches and tags as first-class citizens, and the fact that it does so brings some nice benefits.</p></blockquote>Tags are simply names applied to a particular point in the commit timeline.  Adding them won&rsquo;t increase your download time or consume more of your local workstation disk.  <br /><br />Similarly, branches are stored intelligently by Git.  Adding one won&rsquo;t increase your disk consumption, as deltas are used to keep track of what&rsquo;s what internally.<br /><br />All this combines to my next point:<h2>Better Performance</h2>Because branches and tags don&rsquo;t come down as redundant data, performance is substantially better over the wire.<br /><br />To benchmark just how much better, I timed a full checkout of a large, long-lived SVN project containing dozens of tags and a couple of branches.  <br /><br />The original SVN repo was converted to Git and hosted on the same server for comparison purposes.<br />The results speak for themselves:<br /><br /><strong>SVN: </strong>The repository took <strong>30:09 minutes</strong> to download, and consumed <strong>3.86GB</strong> of disk.<br /><strong>Git: </strong>The repository took <strong>2:22 minutes</strong> to download, and consumed <strong>187.6MB</strong> of disk.<blockquote><p>Git sends much less data over the wire than SVN and consumes less disk on your workstation.</p></blockquote>This is even more impressive when you consider my next point:<br /><h2>Local Commit History</h2>SVN only gives you a snapshot in time.  If your server went away for some reason, the checkin history would be lost; you&rsquo;d only have the latest copy of trunk and each tag on your local workstation.<br /><br />Git instead gives you the <strong>entire</strong> repository, with all checkin history back to the initial creation of the repo.  This is a &ldquo;nice-to-have&rdquo; feature for redundancy, but it also becomes another performance benefit when diffing files, viewing checkin history, etc.  All these operations can run locally rather than over the wire.<br /><blockquote><p>Despite consuming less disk, Git puts more information on your workstation and gives you the entire repository commit history.</p></blockquote> <h2>Better Renames</h2>Renaming files on SVN is a somewhat dicey operation that ends up committing as two operations: a delete, and an add.  Git is able to identify that the file itself did not change, and it registers this as what it is: a rename.<br /><h2>No .svn Droppings</h2>SVN makes a hidden file in every folder of your project called &ldquo;.svn&rdquo;.  These files can become troublesome when copying folders between projects.  For example, say you want to pull a copy of JSONKit from project1 into project2 - the /JSONKit folder will contain it&rsquo;s own .svn folder which must be deleted, or SVN will become confused at commit time.<br /><br />This is a bigger and more pervasive issue than it sounds like.  Any serious SVN user knows this command for deleting all hidden .svn folders and starting from scratch:<br /><br /><code>find -name "\.svn" -exec rm -rf {} \;</code><br /><br />By comparison, Git stores only one .git folder and it&rsquo;s in the root directory of the project.  If you ever want to de-gittify a project, just delete one .git folder and you have a clean copy ready to import somewhere else.<br /><br />Any SVN users who have struggled with issues related to .svn folders will appreciate this.<h2>Better Branching</h2>As I mentioned previously, branching in SVN was an activity I tried to avoid as much as possible.  <br /><br />Creating a branch in SVN is a fairly nasty operation:<br /><ul class="disc"><li>Copy your trunk folder to the branches folder (which makes a full copy of the project)</li><li>Do your experimental work in the branch</li><li>Merge it back to trunk and delete the experimental branch</li></ul>Because the process works by copying the entire source folder, it can be a fairly intensive operation&hellip;and merging back is often a nail-biting experience.  Sometimes I didn&rsquo;t even bother to merge back; I&rsquo;d just copy the commits I needed by hand back to trunk.<br /><br />With Git, branching is fast, lightweight, and effortless.  You can create as many branches as you like, and switching between them is like changing channels on a TV - it just happens, and your working folder is suddenly updated.  It&rsquo;s so fast and effortless that it encourages branching as part of your development workflow.<br /><br />To get a full understanding of the power of branching and why you&rsquo;ll want to do more of it in Git, I recommend reading <a href="http://progit.org/book/" rel="self">Pro Git </a>- it&rsquo;s a great explanation.<br /><br /><h1>Ok, I&rsquo;m Sold - How Do I Convert?</h1> <h2>Step 1: Prepare the SVN Repos</h2>If you have one giant repo for all your projects, you should first split them into individual per-project repos.<br />If you&rsquo;re already using separate repos for each project, skip this step.<br /><br />This requires using svnadmin filters and for me was the biggest and most time consuming part of switching.<br />The basic process is:<br /><ul class="disc"><li>Dump your repo using svnadmin dump</li><li>Create a new repo</li><li>Load the new repo using svndumpfilter, filtering to only the folder(s) you care about for the new project-centric repo.</li></ul>I&rsquo;m not going to go into detail on svndumpfilter as there&rsquo;s <a href="http://mikemason.ca/blog/2005/10/splitting-merging-and-organizing-a-subversion-repository/" rel="self">plenty of info on The Googles</a> about this.<br /><h2>Step 2: Convert the Repos</h2>Once you have nice, separated per-project SVN repos, you can easily convert each one to a nice fresh Git repo.<br /><br />The best information I found about this comes from <a href="http://www.albin.net/" rel="self">John Albin.</a><br /><br />If you just have one repository to convert, follow his 7 step process here:<br /><a href="http://www.albin.net/git/convert-subversion-to-git" rel="self">http://www.albin.net/git/convert-subversion-to-git</a><br /><br />If you have a lot of repositories to convert, or you just prefer automation, look at his pre-built scripts that automate the process here:<br /><a href="http://www.albin.net/git/git-svn-migrate" rel="self">http://www.albin.net/git/git-svn-migrate</a><h1>Conclusion</h1>In summary, most of my trepidation about switching to Git was unfounded, and the benefits of making the move have made me a believer.  I hope that you&rsquo;ll consider giving Git a try too!<br />]]></content:encoded></item></channel>
</rss>
