Saturday, May 1, 2010

How to use SVN (Subversion)

"Subversion" is the version control system used in the php-tsql project. To contribute to it we have to use the subversion(svn) client in our local machine. This article includes the basic usage of subversion.

To install subversion,

sudo apt-get install subversion

To download the project's source files, you should create a directory somewhere in your
machine and go into that directory from shell,
Now give the command,

sudo svn checkout http://path to the project

eg:
sudo svn checkout http://192.248.16.125/svn/php-tsql/trunk


Now you can do editing of your files. But when you add or delete files/folders to the source directory you have to do it also in the command line.

To add a new file or directory to the source directory,

sudo svn add path/fileOrFoldername

eg -
(you're in the directory which you created to get the source files)
sudo svn add trunk/newfile.c

sudo svn add trunk/newDirectory

sudo svn add trunk/newDirectory/newfile2.c


You can delete a file or folder in a similar way,

sudo svn delete trunk/newfile2.c

sudo svn delete trunk/newDirectory


After you're done with the editing of source code, you have to commit it back to the repository.

sudo svn commit trunk/


When we commit we can put a log message which may be useful to track the purpose of editing the source of previous committed revision. To add the log message,

sudo svn commit trunk/ --message "This is the log message."

There are lot's of svn command available, following links will be helpful.
http://svnbook.red-bean.com/en/1.0/index.html

http://linux.byexamples.com/archives/255/svn-command-line-tutorial-for-beginners-1/