In this tutorial i’ll explain what is SVN , why we use it and it’s popular commands.
What is SVN
SVN (Subversion) is an open-source version control system. It is widely used for maintaining current and historical versions of files and directories. Using SVN you can track changes in files and directories.
How to Install SVN – Download Guide
1.
How to Install SVN on Ubuntu
1 |
# sudo apt-get install subversion |
Install, Uninstall package through apt-get .
2.
How to Install SVN on Windows
Download the SVN package
according to whether your system is 32 bit or 64 bit. Once downloaded install it and you’r done.
SVN Commands
SVN Checkout command
SVN provides checkout command to check out a working copy from a repository.
1 2 3 |
# svn checkout urlpath # svn checkout http://svn:8080/svn/current_project |
Or instead of writing checkout you can use co as well.
1 2 3 |
# svn co urlpath # svn co http://svn:8080/svn/current_project |
This command create the new directory current_project in the current working directory.
SVN Info
Svn info command is used to check information such as Date modified, author, revision, path in repository.
It will shows
a) Repository info from which the object is versioned.
b) Most recent commit.
c) Any user-level locks held on the object.
d) Local scheduling information (added, deleted, copied, etc.)
e) Local conflict information.
Go to the current project (working directory) and type svn info, it will display all these information.
1 |
# svn info |
It shows information such as
1 2 3 4 5 6 7 8 9 |
URL: http://svn:8080/svn/current_project Repository Root: http://svn:8080/svn/current_project Repository UUID: ebb41b07-8871-4b90-CC77-68c30ca78913 Revision: 3240 Node Kind: directory Schedule: normal Last Changed Author: raj Last Changed Rev: 3456 Last Changed Date: 2012-11-16 11:34:15 +0530 (Fri, 16 Nov 2012) |
SVN commit command
When you made some changes in code then intially it is not save in svn server until you commit your changes through svn ci command.
Syntax –
1 |
# svn ci filename -m "comment" |
1 2 3 4 5 |
# svn commit products.php -m "comment feature introduced" Adding products.php Transmitting file data. Committed revision 3245. |
I have made changes in products.php file so i have to commit those changes in svn. After -m switch mention your comment so that whenever you check logs you know the changes you have done in this revision.
SVN add command – Add new file in SVN
SVN add command add new file in svn repository. While working on some feature you have created new file so before committing changes you have to add those files in SVN .
Syntax-
1 2 3 4 5 |
# svn add filename or # svn add file1,file2,file3 |
1 2 3 |
# svn add comment.php A comment.php |
I have added comment.php in SVN. Next step is to commit your changes.
1 2 3 4 |
# svn ci comment.php -m "comment feature for users" Transmitting file data . Committed revision 3269. |
SVN status command
It prints only locally modified items.
1 2 3 4 5 |
# svn status M .htaccess M current_project/products.php M current_project/comments.php |
You can use svn st(shorter version of svn status) command for the same purpose.
SVN help
If you need any help, you can use man command in Ubuntu.
1 |
# man svn |