Getting Started with Version Control with Subversion

Have you ever tried working on a collaborative project involving multiple contributors without using any special software to manage versions or track changes in files? Just trying to keep track of which file is the latest version of a particular document will be enough to cause many a headache!

Version Control Systems (VCS) on the other hand, are computer software designed specifically to track changes in documents, images, programming codes and other types of files. These tools allow the user to trivially identify the latest version of files, and also retrieve older versions of the files if needed. One of the most popular free version control systems is called Subversion, or SVN for short.

This article provides some basic introductory information that you need to understand in order to do version control with Subversion. Let’s start by defining terminologies.

Terminology

Versioning is a process where the state of a project is committed or saved at a certain point in time. In software development, versioning is necessary for the improvement of the project while still being able to track the changes from previous revisions. This process also ensures that people are working with the latest revision of the files.

The repository is a database where all the file data is saved. It contains the contents of all the files that comprise the project, together with all their previous revisions. In the repository, anyone can check-out a copy of the files onto their local machine, but only an authenticated author can check-in files.

A revision number is used to track all the files inside the repository. With Subversion, this number is incremented by one every time a new version is saved to the repository.

A working copy is a local copy of a particular version of the files. For example, consider a situation where you wish to work on a file in the repository. First, you have to “checkout” that file from the repository and save the file in your computer as a working copy. You then edit the file and make whatever changes you wish to make. When you have finished editing the working copy, it is then committed back to the repository and is saved with a new revision number.

Committing is the process whereby the local changes made in the working copy is sent back to the repository.

A working copy can also be updated with changes made by other uers. For example, consider a situation where you have checked out some files from the repository. In the meantime, someone else has also checked out one of the same files to make other changes and has since committed it back into the repository. You can then update your working copy to the latest version so it matches the revision in the database. This step is necessary to resolve any conflicts and avoid any problems when you commit the file into the repository.

Merging is a process whereby files from two different versions are combined into one final version. When files are merged, any conflicts that may arise must be resolved by the authors.

Typical workflow when using Subversion for version control

Now that you are familiar with some of the terms used in SVN, here is the workflow to manage version control in Subversion.

  1. Determine the operating system of your computer. Then download and install the appropriate version of Subversion on your computer.
    • For Windows users: TortoiseSVN is recommended.
    • For Mac OS users: svnX is recommended.
    • For Linux users: Use your package manager to install the ‘subversion’ package.
  2. Create a repository. There are many ways to do this, depending on whether you want to use a local SVN repository or a hosted SVN solution. Your Subversion software will allow you to create a local repository, however it is generally a good idea to ensure your repository is located on a different computer to your work computer for additional data redundancy.

  3. Checkout the latest revision from the repository. The process for doing this depends on the particular software used, but in all cases you will need to choose a location on your computer to store the working copy. When the checkout has completed, you may start editing the file.

  4. Make necessary changes to improve the files. If multiple users are working on the same files, make sure that you are using the latest version, such that your local copy is in sync with the updates on the repository. And always double check your changes before commiting.

  5. Merge the files and resolve any conflicts that may arise following an update. Subversion will not allow you to commit any changes if there are conflicts that have not yet been resolved.

  6. Commit the changes. Note that when changes are committed, it is very helpful to leave some descriptive notes or log message to indicate why the changes were made. In this way, you can recall the reasons behind the changes should you need to return to the files in the future.

Thats basically it! This information should hopefully be enough get you started with version control with Subversion. Go and focus on your project, and let the software worry about tracking all the changes to your files!



  0 COMMENTS
Version Control

Leave a Reply

Resources