<?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>Mark Kirby - Mobile Developer &#187; subversion</title>
	<atom:link href="http://mark-kirby.co.uk/tag/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://mark-kirby.co.uk</link>
	<description>I'm a user focused mobile developer, here is where I publish advice and thoughts on building great mobile apps</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:18:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to set up and use Subversion (SVN) on OS X Leopard</title>
		<link>http://mark-kirby.co.uk/2008/how-to-set-up-and-use-subversion-svn-on-os-x-leopard/</link>
		<comments>http://mark-kirby.co.uk/2008/how-to-set-up-and-use-subversion-svn-on-os-x-leopard/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 21:33:21 +0000</pubDate>
		<dc:creator>kirby.mark</dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.mark-kirby.co.uk/2008/how-to-set-up-and-use-subversion-svn-on-os-x-leopard/</guid>
		<description><![CDATA[Subversion is a tool which allows you to save code changes and then step back through the changes at a later date, or revert back to previous changes if things go wrong. It provides the following benefits:

Mistakes matter less &#8211; you can always go back
More than one person can work on the same code, without [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion is a tool which allows you to save code changes and then step back through the changes at a later date, or revert back to previous changes if things go wrong. It provides the following benefits:</p>
<ul>
<li>Mistakes matter less &#8211; you can always go back</li>
<li>More than one person can work on the same code, without conflicts</li>
<li>If you work on more than one machine you can save the code in a central location</li>
<li>Loads more on the <a href="http://subversion.tigris.org/">subversion website</a></li>
</ul>
<p>If you do all your development on one machine and work alone, then you can get away with installing Subversion on your local machine (make sure you back everything up though!), this tutorial is aimed at you.</p>
<p>This tutorial is aimed mainly at Leopard users, who have Subversion pre-installed, but if you are using Tiger and have managed to install Subversion yourself it will work for you too.</p>
<h2>Setting up the SVN Repository area on OS X</h2>
<p>SVN comes preinstalled on OS X, but there is a little more work to be done before you can use it properly.</p>
<p>Open up terminal, and start by creating the folder that will hold your applications repositories:<br />
<code lang="bash"><br />
$ sudo mkdir /usr/local/svn<br />
</code><br />
Change ownership of this folder to www so it can be accessed through the web browser and the svn system will work:</p>
<p><code lang="bash">$ sudo chown -R www:www /usr/local/svn </code></p>
<p>Go into the apache conf area and edit svn.conf:</p>
<p><code lang="bash"><br />
cd /etc/apache2/other<br />
pico svn.conf<br />
</code></p>
<p>Enter the text</p>
<p><code lang="bash"><br />
LoadModule dav_svn_module /usr/libexec/apache2/mod_dav_svn.so<br />
<location><br />
DAV svn<br />
SVNParentPath /usr/local/svn<br />
</location><br />
</code></p>
<p>Save the text</p>
<p>Restart Apache:</p>
<p><code lang="bash">$ sudo apachectl graceful</code></p>
<h2>Setting up a repository into OS X</h2>
<p>Now we have our svn area set up, lets imagine we want to create a repository for a project, perhaps one we&#8217;ve already been working on before (although this will work even if you haven&#8217;t yet started).</p>
<p>First we want to create a sample set of folders which can be used time and time again to set up the default folder structure of the SVN repository. Choose a location on your system &#8211; I&#8217;ve done it in /Library/WebServer/Documents, and create the folder svn_default and within that /trunk, /branches and /tags. You can do this from terminal using the following commands:<br />
<code lang="bash">sudo mkdir /Library/WebServer/Documents/svn_default<br />
sudo mkdir /Library/WebServer/Documents/svn_default/trunk<br />
sudo mkdir /Library/WebServer/Documents/svn_default/branches<br />
sudo mkdir /Library/WebServer/Documents/svn_default/tags<br />
</code><br />
Now we need to create your repository in the svn area we set up recently. Enter the following into terminal, substituting appname for the name of your app:<br />
<code lang="bash">sudo svnadmin create /usr/local/svn/appname</code></p>
<p>Check everything worked by going to http://localhost/svn/appname/.<br />
You should see a webpage with a heading of Revision 0: /</p>
<p>Now you need to give the www authority to change files, so stick this into terminal<br />
<code lang="bash">sudo chown -R www:www /usr/local/svn</code></p>
<p>Next we want to create our default file system inside the SVN repository, so put the following into terminal:</p>
<p><code lang="bash">svn import -m "initial import" /Library/WebServer/Documents/svn_default http://localhost/svn/appname</code></p>
<p>You should see the following output:<br />
<code lang="bash">Adding         /Library/WebServer/Documents/svn_default/trunk<br />
Adding         /Library/WebServer/Documents/svn_default/branches<br />
Adding         /Library/WebServer/Documents/svn_default/tags<br />
Committed revision 1.<br />
</code></p>
<p>Take a look at http://localhost/svn/appname, the heading should now say Revision 1, and you will see links showing the filesystem you added.</p>
<p>Now you want to put the working version of your app into the trunk folder. In my case, the app i want to add is in the Documents folder, and thats also going to be the place I want to continue working on it. Put the following into terminal, where /Library/WebServer/Documents/appname links to the location of your app.</p>
<p><code lang="bash">svn import -m "app import" /Library/WebServer/Documents/appname http://localhost/svn/appname/trunk</code></p>
<p>You should now see all the files adding into the SVN repositiory, and at http://localhost/svn/appname you should be able to click on the Trunk link and see the files.</p>
<p>Now all the files are in the SVN, you need to check them out for the first time in order to start working on them.If you, like me, want to work on the same folder as the one you just uploaded from, you will need to remove that folder before continuing.</p>
<p><code lang="bash">sudo rm -r /Library/WebServer/Documents/appname</code></p>
<p>Then go to the directory above the one you want to work with &#8211; so instead of appname (which should no longer be in Documents anyway), go to Documents.</p>
<p><code lang="bash">cd /Library/WebServer/Documents</code></p>
<p>Then checkout the files</p>
<p><code lang="bash">svn checkout http://localhost/svn/appname/trunk appname</code></p>
<p>Now you should see the files in the appname folder. Well done, you can now make changes to files and use the commands listed below to add the changes and retrieve them from the SVN system.</p>
<h2>Working with SVN repositories on OS X</h2>
<p>Now you have a working repository you can use various commands to save and retrieve code changes.</p>
<p>You first must always navigate to the folder you set up in terminal, so following the above example it would be</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<h3>Get the latest code</h3>
<p>When you start work you should update to get any changes made, if more than one person is making changes to the code.</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<p><code lang="bash">svn update</code></p>
<h3>Find differences you made since the last commit</h3>
<p>After updating, you might change some files, to find out what files you changed run</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<p><code lang="bash">svn  status</code></p>
<p>To find out exact changes run</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<p><code lang="bash">svn diff</code></p>
<h3>Set a file back to how it was before</h3>
<p>You&#8217;ve changed a file, but haven&#8217;t commited, and you don&#8217;t like what you&#8217;ve done. You can easily go back to the last committed copy by typing the following:</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<p><code lang="bash">svn revert path/to/file.php</code></p>
<p>where path/to/file is the path from but not including appname. e.g. if I made an error in appname/path/to/file.php I would use the above path</p>
<h3>Saving changes</h3>
<p>After making all your changes you can save them back into the repository with the following command:</p>
<p><code lang="bash">cd /Library/WebServer/Documents/appname</code></p>
<p><code lang="bash">svn commit -m "Describe the changes you made"</code></p>
<h3>Adding a group of new files</h3>
<p>When you add new files to a project they won&#8217;t automatically get added by Subversion. You can either add them one by one using</p>
<p><code lang="bash">svn add filename_or_dirname</code></p>
<p>or try</p>
<p><code lang="bash">svn --force add .</code></p>
<h3>Removing files</h3>
<p>To remove a file or folder from your project, don&#8217;t just delete it from your local file system. Instead do this:</p>
<p><code lang="bash">svn delete filename_or_dirname</code></p>
<p>That marks them for deletion and removes it from the local file system, when you next commit, they will be deleted from the svn repository:</p>
<p><code lang="bash">svn commit -m "removing files"</code></p>
<h3>Tagging a version of your code</h3>
<p>If you are happy with a version of your code and want to take a snapshot to make it easier to roll back should problems arise with the next version, you can create a copy with a tag. Remember the tags folder we created, thats a good place to put these tagged versions. Users can then download them from here, and not worry about small changes you may have made since.</p>
<p>To do this:</p>
<p><code lang="bash">svn copy http://localhost/svn/appname/trunk http://localhost/svn/appname/tags/release-1.0 -m "Tagging the 1.0 release of the 'appname' project."</code></p>
<h3>Creating a Branch</h3>
<p>If you want to make a branch to continue working on a project, perhaps in a different way to before, a branch should be created.</p>
<p>To create a branch</p>
<p><code lang="bash">svn copy http://localhost/svn/appname/trunk http://localhost/svn/appname/branches/branch1 -m "new branch"</code></p>
<h2>We&#8217;re done</h2>
<p>Thats enough to get started, for more information <a href="http://svnbook.red-bean.com/">download the free Subversion </a>book.</p>
]]></content:encoded>
			<wfw:commentRss>http://mark-kirby.co.uk/2008/how-to-set-up-and-use-subversion-svn-on-os-x-leopard/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
