<?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>casperfabricius.com &#187; subversion</title>
	<atom:link href="http://casperfabricius.com/site/category/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://casperfabricius.com/site</link>
	<description>expert ruby on rails development</description>
	<lastBuildDate>Sun, 06 Jun 2010 08:43:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting started using Subversion on Windows</title>
		<link>http://casperfabricius.com/site/2006/04/19/subversion-tutorial/</link>
		<comments>http://casperfabricius.com/site/2006/04/19/subversion-tutorial/#comments</comments>
		<pubDate>Wed, 19 Apr 2006 19:50:16 +0000</pubDate>
		<dc:creator>Casper Fabricius</dc:creator>
				<category><![CDATA[subversion]]></category>
		<category><![CDATA[tutorial]]></category>

	<!-- AutoMeta Start -->
	<category>subversion</category>
	<category>tutorial</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://casperfabricius.com/blog/2006/04/19/subversion-tutorial/</guid>
		<description><![CDATA[Subversion is a brilliant piece of open-source software for version control. It is the heir of the renowned CVS and suprior to the infamous SourceSafe in every way. This tutorial is not about running a Subversion server &#8211; although it is easy and free &#8211; but about using Subversion for easy collaboration and version control [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion is a brilliant piece of open-source software for version control. It is the heir of the renowned CVS and suprior to the infamous SourceSafe in every way. This tutorial is not about running a Subversion server &#8211; although it is easy and free &#8211; but about using Subversion for easy collaboration and version control in Windows.</p>
<p><strong>What is version control?</strong></p>
<p>Version control is basically about storing different versions of the same files, which enables you to go back previous versions in case you mess something up. Since the files are usually stored on a central server &#8211; often, but not necessarily, accessible from the internet &#8211; a nice side effect of version control is that it enables several people to work with the same set of files simultaneously, by letting everyone syncronize their files with the server.</p>
<p><strong>What is a repository?</strong></p>
<p>Remember the central server running Subversion? This is where the repositories is located. Each repository is a unique and seperate collection of files with a forthrunning version number. You usually create a new repository for each new project you choose to version control, but in case you can&#8217;t just create new repositories, there is no problem in grouping several projects in the same repository.</p>
<p>I assume that you already know two things: The url of the Subversion repository you want to work with, and the username and password to use with it. If not, feel free to expirement with (but not abuse) a test repository I have setup for this tutorial:</p>
<ul>
<li>Url: <a title="Test repository" href="http://svn.casperfabricius.com/sandbox/">http://svn.casperfabricius.com/sandbox/</a></li>
<li>Login: test</li>
<li>Password: test</li>
</ul>
<p><strong>TortoiseSVN &#8211; making Subversion easy</strong></p>
<p><img align="right" alt="Downloading TortoiseSVN" title="Downloading TortoiseSVN" src="http://casperfabricius.com/blog/gfx/download-tortoisesvn.png" /></p>
<p>Your first step is to install TortoiseSVN; a free open-source client for working with Subversion in Windows, which integrates seamlessly with Windows Explorer. Go on; <a title="Download TortoiseSVN" href="http://sourceforge.net/project/showfiles.php?group_id=138498&#038;package_id=151948">download and install</a> the latest version right now! (Select the TortoiseSVN-X.X.X.XXXX-svn- X.X.X.msi file.)</p>
<p>Once installed; start Windows Explorer or open My Computer from your desktop and create a folder a place where you would like to place your first repository &#8211; I usually keep mine in &#8220;C:\Projects&#8221;. Right-click on the folder (or in the &#8220;white space&#8221; inside it) to discover two new items in your context menu: &#8220;SVN Checkout&#8221; and &#8220;TortoiseSVN&#8221;. Select to &#8220;SVN Checkout&#8221; to make the folder your local working folder for the files in the repository. Enter the url of the repository you want to use, or use &#8220;http://svn.casperfabricius.com/sandbox/&#8221;. Enter your username and password (both are case-sensitive) or use test as both if you are checking out my test repository. I recommend that you check the &#8220;Save authentication&#8221; box, unless you are not using your own computer. I might encounter the message saying &#8220;Error validating server certificate &#8230;&#8221; during the process, if the repository is using SSL. It&#8217;s not a problem at all, just select &#8220;Accept Permantly&#8221; and go on with the tutorial. TortoiseSVN will now download any files in the repository to the folder, and add several new items to the context-menu, enabling you to syncronize with the Subversion repository. Your are ready to start using the repository!</p>
<div class="c_clear"></div>
<div class="c_centerlist_left">1.</div>
<div class="c_centerlist_right"><img title="Checkout step 1" alt="Checkout step 1" src="http://casperfabricius.com/blog/gfx/svnscheckout-1.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">2.</div>
<div class="c_centerlist_right"><img title="Checkout step 2" alt="Checkout step 2" src="http://casperfabricius.com/blog/gfx/svnscheckout-2.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">3.</div>
<div class="c_centerlist_right"><img title="Checkout step 3" alt="Checkout step 3" src="http://casperfabricius.com/blog/gfx/svnscheckout-3.png" /></div>
<div class="c_clear" /></div>
<p><strong>Commit and update &#8211; your two basic commands</strong></p>
<p>Basically, the point with Subversion is all about sharing your changes with others, and in turn getting their changes reflected in your local working copy of the repository. When you upload you files to the repository on the central server, you are in fact &#8211; in Subversion slang &#8211; <i>commiting</i> your changes. Every time some one commits a change, the Subversion server creates a new version of the repository. Not that it copies every single file in the repository each time a change is commited, but it creates <i>change sets</i> which enables the server to produce an exact copy of the repository in any given version. Even deleted files still exists in previous versions, so once you have commited something, you can always get it back later, no matter what changes other people make.</p>
<p>So how do you actually commit files? You right on the folder or inside the folder with the files you want to commit, and select &#8220;SVN Commit&#8221; from the context menu. This brings up an overview of all the files you have changed <i>and</i> new files that has not yet been <i>added</i> to the repository. You must actively check the box for new (non-versioned) files to get added and committed to the repository. You don&#8217;t have to add all files in the folder to the repository, actually; you should make sure that generated files &#8211; such as dll-files genereated from code files &#8211; are <i>not</i> added to the repository.</p>
<div class="c_clear"></div>
<div class="c_centerlist_left">1.</div>
<div class="c_centerlist_right"><img title="Commit step 1" alt="Commit step 1" src="http://casperfabricius.com/blog/gfx/commit-update.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">2.</div>
<div class="c_centerlist_right"><img title="Commit step 2" alt="Commit step 2" src="http://casperfabricius.com/blog/gfx/commit-box.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">3.</div>
<div class="c_centerlist_right"><img title="Commit step 3" alt="Commit step 3" src="http://casperfabricius.com/blog/gfx/commit-status.png" /></div>
<div class="c_clear" /></div>
<p>Updating &#8211; as you have probably guessed by now &#8211; is simply a matter of selecting &#8220;SVN Update&#8221; in the context menu and letting magic happen.</p>
<p><strong>Merging and conflicts &#8211; two people; one file</strong></p>
<p>But what happens if two people make changes to the same file? The scenario goes like this:</p>
<ol>
<li>Bob and Alice both change helloworld.txt</li>
<li>Alice commits her version of the file, unknowingly that Bob has also made changes</li>
<li>Now Bob commits his version of file, but get&#8217;s an error message; his file is out of date</li>
<li>Bob fixes this by updating his local working copy, and most likely; Subversion is able to merge his changes automatically with Alice&#8217;s changes.</li>
<li>If Subversion cannot merge the changes; a conflict occurs.</li>
<li>Bob now needs to navigate to the conflicted file, select &#8220;TortoiseSVN > Edit conflicts&#8221; and the context menu for the file, manually merge the two files using the build-in program, and mark the conflict as resolved.</li>
<li>Bob are now able to commit his version of the file, which contains both his and Alice&#8217;s changes.</li>
<li>The next time Alice update, she gets Bob&#8217;s merged file and everyone is happy</li>
</ol>
<div class="c_clear"></div>
<div class="c_centerlist_left">1.</div>
<div class="c_centerlist_right"><img title="Conflict step 1" alt="Conflict step 1" src="http://casperfabricius.com/blog/gfx/conflict-box.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">2.</div>
<div class="c_centerlist_right"><img title="Conflict step 2" alt="Conflict step 2" src="http://casperfabricius.com/blog/gfx/conflict-menu.png" /></div>
<div class="c_clear"></div>
<div class="c_centerlist_left">3.</div>
<div class="c_centerlist_right"><img title="Conflict step 3" alt="Conflict step 3" src="http://casperfabricius.com/blog/gfx/mark-as-resolved.png" /></div>
<div class="c_clear" /></div>
<p>Why does it work like this? Why aren&#8217;t the files &#8220;locked&#8221; so only one person can edit a file at the time? Well, for one thing; this way everyone in a team can work unbothered and even offline on the same set of files, and Subversion will (mostly) be able to merge the changes. If you are used to SourceSafe, it will probably take you a bit of time to get used to the idea, but it is &#8211; in my opinion &#8211; by the best way to work. Embrace merging and even conflicts &#8211; they are always easily resolved. If you can&#8217;t; Subversion also supports locking, but that&#8217;s another story.</p>
<p>One last thing: Subversion can&#8217;t (by default) merge binary files. It&#8217;s not a problem storing Word-documents, Visio-diagrams, Photoshop-images etc. in a Subversion repository, but once a conflict occurs; you are on your own.</p>
<p><strong>Rearranging &#8211; renaming, moving and deleting files.</strong></p>
<p>In time; your repositories grow big and ugly, and you&#8217;ll want to rearrange or clean up the mess. When doing this; it&#8217;s important to be aware that you can&#8217;t just rename, move and delete as you usually do it in &#8220;My Computer&#8221; or Windows Explorer. Well, you can, but Subversion won&#8217;t know it, and will consider a renamed or moved a new file, while restoring the file with the old name in it&#8217;s old location on your next update.</p>
<p>For this reason, you should always use the &#8220;Rename&#8221; and &#8220;Delete&#8221; commands in the &#8220;TortoiseSVN&#8221; sub menu in the context menu. This also applies to folders. Also, if you want to move a file to another folder in the repository, you should <i>drag it with right mouse-button</i> and drop it on the folder you want to move it to. This will open a context menu, and when you select &#8220;SVN Move versioned files here&#8221;, TortoiseSVN will make all the dirty work for you, moving the file to it&#8217;s new location.</p>
<p><img title="Rename and delete" alt="Rename and delete" src="http://casperfabricius.com/blog/gfx/rename-delete.png" align="left" /><br />
<img title="Moving a file" alt="Moving a file" src="http://casperfabricius.com/blog/gfx/move.png" align="right" /></p>
<div class="c_clear" /></div>
<p>The result of sticking to using the rename, delete and move command is that the files will automatically renamed, deleted and moved in other peoples local working copies once they update.</p>
<p><strong>How do I get my own Subversion repository?</strong></p>
<p>If you know me personally, I can probably be persuaded to create a repository for you. If you have our own server, or access to one, you can install Subversion following the instructions on <a href="http://subversion.tigris.org/">http://subversion.tigris.org/</a>.</p>
<p>Otherwise, there are plenty of companies that offers to fullfill all your Subversion needs. I can recommend these two, since I use them my selve:</p>
<ul>
<li><a href="http://www.dreamhost.com">Dreamhost</a></li>
<li><a href="http://www.cvsdude.org">CVS Dude</a></li>
</ul>
<p><strong>Conclusion</strong></p>
<p>I could go on for long about other features of Subversion and TortoiseSVN, but with this; the most basic and important commands and functionality are covered. Happy versioning!</p>
<p>Read more:</p>
<ul>
<li><a href="http://subversion.tigris.org/">http://subversion.tigris.org/</a></li>
<li><a href="http://tortoisesvn.tigris.org/">http://tortoisesvn.tigris.org/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://casperfabricius.com/site/2006/04/19/subversion-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
