A Practical Introdcution to Subversion

By Sagar
Software Engineer


Overview

This document provides a brief tutorial on using Subversion. I’m using this to document the SVN tools as I learn to use them, and tips for administering an SVN repository. This is not intended to be a replacement for the SVN documentation, but rather a quick howto on using SVN.

Using SVN we can work as a team anywhere within a system, intranet or even internet. It keeps track of each activity done on each file with basic information like who made the changes, when and what changes been made. We can easily compare the different version of files. And many more.

Installing SVN

I’ll focus on TortoiseSVN as it is a really easy to use Revision control / version control / source control software for Windows. It is based on Subversion. TortoiseSVN provides a nice and easy user interface for Subversion.

It is developed under the GPL. Which means it is completely free, including the source code. But just in case you don’t know the GPL too well: you can use TortoiseSVN to develop commercial applications or just use it in your company without any restrictions.

Since it’s not an integration for a specific IDE like Visual Studio, Eclipse or others, you can use it with whatever development tools you like.

Download the Subversion interface from http://tortoisesvn.net/downloads and install it.

After you’ve gotten Subversion installed by following the instructions, Now we need to do either of the following.

1.     Create a new Repository – To create a new repository  or

2.     Do SVN Checkout using  URL for repository.


Managing repositories

Subversion manages branches a bit differently than CVS; there’s a good document (SVN for CVS users) at the Subversion site. You should read that. The long short of it is that you have to restructure your directories a little bit before using Subversion. Caveat: this restructuring isn’t neccessary, and the following tree hierarchy isn’t neccessarily the best. However, while the documentation isn’t clear on this subject, it implies that if you don’t do this (or something like this) you may encounter difficulties later when you try to do branches.

Say you have a project that is laid out:

myproject/

index.html

src/

docs/

images/

Before you import the project into Subversion, you should restructure the hierarchy so that it looks like this:

myproject/

tags/

branches/

trunk/

index.html

src/

docs/

images/

You do this because to create a branch “sometag”, you’ll copy trunk/ to branches/sometag.

Anyway, after you’ve moved things around, make sure you’ve deleted any extraneous files, such as *~ and .*.swp. Make sure to delete those CVS directories, or they’ll end up in the repository. Then, in the parent directory of “myproject”, run the command: svn import http://yourhost/svn/repos myproject myprojectDon’t forget the last argument, or else all of the files in myproject will be dumped into the main SVN repository directory… at the top of the hierarchy. To check out the project, use: svn checkout http://yourhost/svn/repos/myproject/trunk -d myproject. This will check out only the “trunk” subdirectory into “myproject” on your machine. You can then work in this subdirectory.

Other commands

Here are common commands I’ve used so far; they operate, for the most part, just like their CVS counterparts, with a few differences (and the power of SVN is in those differences).

  • help — use svn help <command> to get very terse help on any command.
  • commit — just like CVS commit
  • checkout — see the instructions above for an example. Does what CVS checkout does, but with different arguments.
  • update — just like CVS update, although the results are different. See the subversion documentation on the website for more information.
  • delete — deletes a file or directory. Unlike CVS, this really deletes directories. You won’t see the changes in your working directory until you commit and update.
  • status — a useful version of the CVS status command. Works offline and produces human-readable output.


Overview

This document provides a brief tutorial on using Subversion. I’m using this to document the SVN tools as I learn to use them, and tips for administering an SVN repository. This is not intended to be a replacement for the SVN documentation, but rather a quick howto on using SVN.

Using SVN we can work as a team anywhere within a system, intranet or even internet. It keeps track of each activity done on each file with basic information like who made the changes, when and what changes been made. We can easily compare the different version of files. And many more.

Installing SVN

I’ll focus on TortoiseSVN as it is a really easy to use Revision control / version control / source control software for Windows. It is based on Subversion. TortoiseSVN provides a nice and easy user interface for Subversion.

It is developed under the GPL. Which means it is completely free, including the source code. But just in case you don’t know the GPL too well: you can use TortoiseSVN to develop commercial applications or just use it in your company without any restrictions.

Since it’s not an integration for a specific IDE like Visual Studio, Eclipse or others, you can use it with whatever development tools you like.

Download the Subversion interface from http://tortoisesvn.net/downloads and install it.

After you’ve gotten Subversion installed by following the instructions, Now we need to do either of the following.

1.     Create a new Repository – To create a new repository  or

2.     Do SVN Checkout using  URL for repository.


Managing repositories

Subversion manages branches a bit differently than CVS; there’s a good document (SVN for CVS users) at the Subversion site. You should read that. The long short of it is that you have to restructure your directories a little bit before using Subversion. Caveat: this restructuring isn’t neccessary, and the following tree hierarchy isn’t neccessarily the best. However, while the documentation isn’t clear on this subject, it implies that if you don’t do this (or something like this) you may encounter difficulties later when you try to do branches.

Say you have a project that is laid out:

myproject/

index.html

src/

docs/

images/

Before you import the project into Subversion, you should restructure the hierarchy so that it looks like this:

myproject/

tags/

branches/

trunk/

index.html

src/

docs/

images/

You do this because to create a branch “sometag”, you’ll copy trunk/ to branches/sometag.

Anyway, after you’ve moved things around, make sure you’ve deleted any extraneous files, such as *~ and .*.swp. Make sure to delete those CVS directories, or they’ll end up in the repository. Then, in the parent directory of “myproject”, run the command: svn import http://yourhost/svn/repos myproject myprojectDon’t forget the last argument, or else all of the files in myproject will be dumped into the main SVN repository directory… at the top of the hierarchy. To check out the project, use: svn checkout http://yourhost/svn/repos/myproject/trunk -d myproject. This will check out only the “trunk” subdirectory into “myproject” on your machine. You can then work in this subdirectory.

Other commands

Here are common commands I’ve used so far; they operate, for the most part, just like their CVS counterparts, with a few differences (and the power of SVN is in those differences).

  • help — use svn help <command> to get very terse help on any command.
  • commit — just like CVS commit
  • checkout — see the instructions above for an example. Does what CVS checkout does, but with different arguments.
  • update — just like CVS update, although the results are different. See the subversion documentation on the website for more information.
  • delete — deletes a file or directory. Unlike CVS, this really deletes directories. You won’t see the changes in your working directory until you commit and update.
  • status — a useful version of the CVS status command. Works offline and produces human-readable output.

About sansatechnology

Sansa Technology is an IT staffing, Consulting and Training company located in the heart of Silicon Valley. If you are a consultant looking for your new gig, send us your resume to us. If you are looking for training in the field of White Box Testing, Java, Java EE, Selenium, DevOps, Android and others, connect with us as well. Visit us at www.sansatechnology.com or email contact@sansatechnology.com
This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to A Practical Introdcution to Subversion

  1. Subversion can be difficult to understand or grasp if you are new to it or have only had a brief introduction to it. If you follow systematic steps like this, however, you can easily get a subversion download that will work wonders for you and your system as far as data storage, continual change and update and retrieval goes.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s