SVN operating principles, the basic commands

Author: Eugeniy Marilev
Date of publication: 2014-05-06 10:46:10

One of the most common version control systems in the whole world is SVN. It's been used by a good third of all developers. Why is it so popular - just because it is very easy to use, the most convenient graphical clients have been written for it.

Operating principles SVN

SVN uses the principle of storing revisions in the form of patches in its basis. Patch - is a special text file of a specific format that contains information about changes made to a specific file. Namely, the rows which have been added, which have been removed. Each revision in SVN is an archive with patches for all the changed files. SVN stores the data in the repository (storage), which is under the control of the SVN server. Thus, you can place the repository both on the local computer, or somewhere remotely, so anyone can get access to it if you allow. If you wonder how to set up your SVN-server, information can be found here.

Basic operations SVN

So, let's assume you have an empty remote SVN repository. In order to get to work with it, you have to recreate its contents on your computer, that is to make a local copy of the repository. This operation is in terms of SVN is called «checkout». To work with SVN three basic operations are used:

  1. «update» — update the state of the repository to the last committed revision. This function is needed when the project is run by several people. Imagine that you get down to work, and you need to download to your computer all the changes that have been made lately by your colleagues. That's it! Then you made the operation «update».
  2. «commit» - fixation of changes that have been done from the local copy to the repository, i.e. the creation of a new revision. Once you have completed the work, or in the process when you have reached a logical point, the state of which you want to save, with the ability to go back to it, you need to make «commit».
  3. «add» - the addition of a new resource in the repository. Here, please, pay special attention to all new files and folders, which are not yet in the repository must be added manually, so that they fall into the commit, by the operation of «add».

To get started with SVN it's enough to have four operations mentioned above, and in the process you can learn all the others.

Working with SVN using the graphical clients

Working with graphical SVN-clients is easier, faster and more clear to a novice user so my personal advise would be to start your work with SVN with them. Next I will tell you how to work with SVN using the console client, but it is best to use when you get the basic experience. Very good graphical SVN-clients are implemented for a family of Windows operating systems:

  1. VisualSVN.
  2. TortoiseSVN.

Personally, I recommend using TortoiseSVN, as it integrates into the context menu of the Windows (Explorer) file manager, and even in Total Commander. This will allow you to save a lot of time because you do not have to create special bookmarks to a local copy, and you'll be performing all the operations through the context menu. For MacOS there is a comfortable, not free though , SVN client called «Versions», you can download it here . This client, for what it gets a bonus point, can work not only with SVN, but with a version control system git. For a Linux family operating systems, there is a whole bunch of SVN clients, among which there are the following:

  1. RapidSVN — to use as the graphics engine of GUI GTK + 2.0. It works quickly, but it looks very shabby.
  2. RabbitVCS — is an analogue of TortoiseSVN for Linux. Is relatively slow, but on the other hand there is integration with the context menu of the «Nautilus» File Manager . This client also supports git.
  3. KDESVN — SVN client, which is famous for comfortable, intuitive graphical user interface, very stable program. Disadvantage - pulls a lot of dependencies: all graphical libraries KDE, which is not very good for people with Gnome, Xfce etc. desktop.
For installation we are using respectively:
  1. sudo aptitude install rapidsvn
  2. sudo aptitude install rabbitvcs-nautilus
  3. sudo aptitude install kdesvn

Here, I can suggest to use RabbitVCS for Gnome, but if anyone has KDE - get yourself KDESVN.

Working with SVN using the console client

The main console client for *nix like systems is the client with open code, called «svn-client», which comes in a package «subversion». That means, you can install it by running the command in the console:

sudo aptitude install subversion

The actions described above about the usage of the SVN repository are performed as follows:

svn checkout protocol://[user@]repository-domain[repository-path] local-directory-path

- Creating a local copy of repository, where:

  • protocol — access protocol to the repository. The most commonly is used native application protocol «svn», as an alternative to it access can be through the http protocol.
  • user — user's login on whose behalf the authorization will be performed to the repository. If the repository allows access to it for the anonymous users, you can omit the user.
  • repository-domain — domain name of the server where the svn repository is. For example, devdream.net.
  • repository-path — the relative path to a resource within the repository. Usually used for those cases when you need only a specific folder or repository branch. This parameter can be omitted.
  • local-directory-path — a relative path within the file system of your computer where svn-client will store the local copy of the repository. If this parameter is omitted, the default one is to use the current folder.
svn up

- «update» of a local copy.

svn add [local-resource-path]

- adding the resource to the repository where:

  • local-directory-path — the relative path to a resource within the file system of your computer (file or folder), which will be added to the repository. In the case of the folder, all sub-folders and files will also be added. To force ignoring the recursive addition you should use the «--non-recursive» after the «add» command.
svn commit --message='some message'

- «commit» (save) changes.

Conclusion

That's right, we briefly told about the basics of working with SVN. More can be found from other more narrow focused articles. That's, probably, it, as conversation may be endless ... Enjoy working with SVN ...

Article comments
Comments:
No results found.
Only logged users can leave comments.