Subversion is a software for version-control which means that it helps you to store changes you make to files, so you can revert edits, restore deleted files, and much more. In this post I will list the most important subversion commands, from creating a repository on a remote server to committing and updating locally on the machine you are working on. In another post I explain how to synchronize you repository automatically and in yet another I compare some commercial providers of remote backup servers.
About two weeks ago my hard disk failed. I got a new one the following day from our vendor and had my system configured very fast (see other post). Unfortunately I cannot say the same of my data. The server I had been using for backups had been crashing all the time and I was lazy in catching up again with my backups. In consequence I lost two posters I had created. I was very angry with myself. As a reminder to myself this post is about subversion.
Subversion can help you to keep track of changes you make to documents. You can work on a project with other people, manage versions of your files, undo changes, and much more. I use it to be able to make changes fast and always be able to roll-back any time, and as a backup system. Many programmers use version control systems such as subversion, however it can be used with any textual documents.
Subversion can be used completely from the command line, however there are several graphical interfaces to control your versions by clicks of some buttons (examples). In order to use subversion it is important in any case to know how it works. In this post I will explain step by step how to use subversion
It is important to understand the concepts of client and server. They may refer to different computers, however the difference is rather conceptual. All revisions to your files are stored on the server. The server can be remote, this means you use a different computer. You work on a local computer, a client, make changes to your files, and then synchronize with the server.
Instead of a written introduction to subversion, you may watch this video to learn what subversion is.
Basic Subversion CommandsWe will first need to create a repository on the server and then tell subversion that a directory on a local machine we are working on corresponds to that repository. After that we can start committing local changes and update our local files.
On your server you create a subversion project:
Locally, you can start working, starting by checking out the project from the server:
svn co svn+ssh://url
You need to give the full (absolute) path to the directory (otherwise you'll get "no repository found").
If you have your repository on the same computer use instead:
svn copath local_directory
Here you can give a relative directory.
svn cofile:///home/yourname/svnrep/ newprojectpath
Now we can start working by creating files and editing them. We add the files to the version control:
Finishing work (or always after having made some major changes), we commit the changes to the repository:
svn commit -m"changelog"
Next time you start working, if you made changes from another computer, do an update:
or (if you are not in the directory)
We can always check out all subversion commands by typing
svn helpand get help on a command by typing
svn update command.
svn statusalways gives you summary information about whether and how your data is changed:
It is often useful to be remembered whether you need to add some more files to the version control:
svn status | grep ^?
I find symbolic links very useful. Subversion recognizes and can administrate symbolic links, however if you had a file which you want to change for a symbolic link, you need to set the svn:special property of the file (otherwise you get the error svn:
Entry 'yourfile' has unexpectedly changed special status):
svn propset svn:special onfilename
In the contrary case, if you change symbolic links to files delete the svn:special property:
svn propdel svn:specialfilename
That's the basics and you can do with knowing these commands, but of course there's much more functionality, which you kind learn about from the official manuals.
Enjoy. Please leave a comment below for questions and suggestions.