Introduction to Subversion

On my previous post I wrote about installing and configuring Git because I’m really a Git guy, but I have this client now that prefers SVN, short of Subversion version control system, so I had to learn it too. In this post I’m going to introduce you to SVN and how to get it to work. But first, how does it compare to Git?

The main difference of Git and Subversion is that Subversion is centralized; everything happens in a repository on a server, thus you have to be online in order to do anything with SVN at all. On the other hand, Git is decentralized. You have a full copy of what is in the server and can do anything with it offline, and push changes to the server whenever you want. There are also other differences on how they handle tracking of changes, but that’s not the point of this post.

Installation

To install Subversion or otherwise SVN on your computer, if you are running Ubuntu as me, all you have to do is  run this command on the terminal:

sudo apt-get install subversion

That’s it for installing.

Connect to SVN

Now, to start working with it, it means that someone has set up SVN on a server somewhere and you are given an SVN repository URL that you can checkout, which means you fetch the repository contents and meta-data to your local machine. To do that you run:

svn checkout svn://example.com/repopath/reponame

Depending on whether or not the server has you ssh public key, you might be prompted for a username and password. Just enter those to continue.

Check status

The point of version control systems is that it keeps track of your work. After you have made some changes to the files you got from the server and added new files and deleted others, to check what files you have changed you you have to enter your working directory by running cd reponame and then run:

svn status

To actually see what content you have added or deleted on those files your run:

svn diff

Commit Changes

To send the changes you have done to the repository, all you have to do is run:

svn commit -m 'What did you change and why message'

As I told you above, you cannot run this command if you are not connected to the Internet. Remember, SVN is centralized — everything has to happen on the server.

Fetch Changes

To get changes other fellow developers might have done to the files, you run:

svn update

It bring your working copy up-to-date with the repository on the server.

That was it for Subersion at this time. I hope this article was of some help to you.

You may also enjoy…