<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>Vacuous Virtuoso &#187; svn</title>
	<link>http://lipidity.com</link>
	<description>Despotic Development</description>
	<pubDate>Tue, 23 Dec 2008 06:24:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Subversion Basics</title>
		<link>http://lipidity.com/apple/subversion-basics/</link>
		<comments>http://lipidity.com/apple/subversion-basics/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 11:49:18 +0000</pubDate>
		<dc:creator>Ankur</dc:creator>
		
		<category><![CDATA[Apple]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[svn]]></category>

		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://dev.lipidity.com/feature/tutorial/subversion-basics</guid>
		<description><![CDATA[<abbr title="subversion">SVN</abbr> is the next big productivity and collaboration tool to grace the internet. Subversion is the wiki of development, allowing you to track changes, switch to older versions of your project and work as part of a team. Using SVN is a fairly easy process that can be accomplished with extreme ease through the command line.]]></description>
			<content:encoded><![CDATA[<p>Assuming you have access to a subversion repository (such as a project on <a href="http://dev.wp-plugins.org/">wp-plugins.org</a> like <a href="http://www.wordpress.org/extend/plugins/plugin/gregarious">I do</a>), here&#8217;s how you can go about using svn to track changes and work collaboratively.</p>

<p>Open Terminal.app. We&#8217;re going to be using the command line. If you don&#8217;t normally go near the Terminal, don&#8217;t panic. Using svn through the command line is easier than it seems.</p>

<h2>Check it out</h2>

<p>Before we start developing and updating our application, we need to grab a copy of it first. We do this through the <code>checkout</code> command. Checkout, as the name implies, picks up a copy of your application from the repository and downloads it to a location you specify. The checkout command requires to pieces of information. The location of the subversion repository and the location of the folder you wish to download this to. You can omit the latter argument and have subversion download to the current path. For example, if you run <code><acronym title="Change Directory">cd</acronym> ~/project/</code> before using <code>checkout</code>, the contents of the repository will be deposited in <code>~/project/</code>. Let&#8217;s do an example checkout command:</p>

<pre class="code scroll">svn checkout http://svn.example.org/turfapp/ ~/projects/turf/</pre>

<p>Every subversion command you wish to run must be preceded by <code>svn</code> as in the above example. Running the preceding in the Terminal will download the turfapp project (doesn&#8217;t really exist). Now, we&#8217;re ready to get to work!</p>

<p>Once we&#8217;ve checked out a project, we can make edits and updates to our hearts content.</p>

<h2>Ready to Commit?</h2>

<p>When you&#8217;re happy with the changes made, you may upload your work back to the subversion server. However, if you&#8217;re working on a collaborative project, someone may have made a change after you checked out the project. If you upload your copy, it would over-write their work. For this reason, we run the update command.</p>

<pre class="code scroll">
cd ~/projects/turf/

svn update</pre>

<p>This will tell you which revision you have. If everything is fine, we&#8217;re good to upload our changes. We do this by running the commit command. With the commit command, you also need to specify a message about what changes you have made.</p>

<pre class="code scroll">
svn commit -m "Added the Sparkle framework"</pre>

<p>The above assumes you&#8217;re in the correct directory. The message sent to svn would in the example would be &#8220;Added the Sparkle framework&#8221;. Make your message descriptive so anyone else (or even yourself in six months time) can tell what you&#8217;ve done fairly accurately.</p>

<p>Once you&#8217;ve run commit, svn uploads any files that have changed and your updates are saved.</p>

<h2>Adding files</h2>

<h3>Straight add</h3>

<p>If you add a file to the working directory, then run commit, you&#8217;ll find that svn doesn&#8217;t find any changes to update with. Whenever you add files to your working directory that you wish to add to the project, you need to tell svn.</p>

<pre class="code scroll">
svn add newfile.ext</pre>

<p>If the file to be added is in a folder, you&#8217;ll also need to specify that:</p>

<pre class="code scroll">
svn add sources/newfile.h</pre>

<p>Or if the resource you&#8217;re adding is a folder, you can just specify the path:</p>

<pre class="code scroll">
svn add headers/extension/</pre>

<h3>Import</h3>

<p>The import command doesn&#8217;t require you to have a checked out copy of the project, and it allows you to import a file to the server from any location on your hard drive (whereas add is usually restricted to the working directory). For the import command, you need to know the path to the resource, and the path on the server where it should reside. For a folder, you need to specify the path on the server that the folder will take, rather than the path where it should reside as svn will upload the contents of the folder rather than the folder itself. This can be confusing at first if you&#8217;re not aware of it.</p>

<p>The <code>import</code> command will commit the changes you make, so you need to provide a message as well. The overall syntax is:</p>

<pre class="code scroll">
svn import -m "message about update" /Path/To/Resource/ http://svn.location.on/server/trunk/</pre>

<p>Let&#8217;s add a file to our project:</p>

<pre class="code scroll">
svn import -m "Adding about xcode pdf" /Developer/AboutXcode.pdf http://svn.example.corg/turfapp/trunk/resources/</pre>

<p>Will result in the file being uploaded to the server at <code>http://svn.example.corg/turfapp/trunk/resources/AboutXcode.pdf</code>.</p>

<h2>Deleting files</h2>

<p>Now that you can import files, deleting them should be easy. The analog to <code>import</code> is (surprisingly) <code>delete</code>. You can just pass the URL of the file on the server to delete, or you can pass a path to a file in the working directory. If you pass a URL, the change is committed and a message is required. Let&#8217;s get rid of that pdf we imported:</p>

<pre class="code scroll">
svn delete -m "message about deletion" http://svn.example.corg/turfapp/trunk/resources/AboutXcode.pdf</pre>

<p>If you specify a path in the working directory and don&#8217;t send a message, the change is recorded and snchronized with the server the next time you run <code>commit</code>. For example:</p>

<pre class="code scroll">
svn delete trunk/resources/AboutXcode.pdf</pre>

<p>In which case the change is not reflected on the server until you run:</p>

<pre class="code scroll">
svn commit -m "summary of changes"</pre>

<h2>Summary</h2>

<p>SVN can be used to coordinate the development of a project. A project needs to be checked out using the <code>svn checkout</code> into a working directory before it can be edited. Updates are saved using the <code>svn commit</code> command, and files can be added using <code>svn add</code> or <code>svn import</code>, while files are removed using <code>svn delete</code></p>

<p>Some svn commands are analogous to the standard UNIX commands; you can use <code>ls</code>, <code>mkdir</code>, <code>cp</code> etc. to navigate and manage your repository.</p>

<h3>That&#8217;s it!</h3>

<p>You can find out more about subversion at <a href="http://subversion.tigris.org/">http://subversion.tigris.org</a>. Run <code>svn help</code> or <code>svn help subcommand</code> to learn more about the svn commands.</p>

<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://lipidity.com/apple/subversion-basics/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
