≡ Menu

Subversion Tutorial: 10 Most Used SVN Commands with Examples

SVN stands for Subversion.

Subversion is a free/open-source version control system. Subversion manages files and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to your files and directories. This allows you to recover older versions of your code, or examine the history of how your code was changed.

This article explains some basic SVN commands with examples.

SVN Working Copy

SVN is a repository that holds all our versioned data, which is also called as SVN server. SVN client program which manages local reflections of portions of that versioned data which is called as working copy. SVN client can access its repository across networks. Multiple users can access the repository at the same time.

1. SVN Checkout – Create working copy

Checkout command is used to download sources from SVN repository to working copy. If you want to access files from the SVN server, checkout is the first operation you should perform.

SVN checkout creates the working copy, from where you can do edit, delete, or add contents. You can checkout a file, directory, trunk or whole project. To checkout you should know URL of the components you want to checkout.


$ svn checkout/co URL PATH
  • URL is the URL of the components to checkout
  • If PATH is omitted, the basename of the URL will be used as the destination. If multiple URLs are given each will be checked out into a subdirectory of PATH, with the name of the subdirectory being the basename of the URL.

The following example checks out the directory to the given target directory.

$ svn co https://www.thegeekstuff.com/project/branches/release/migration/data/cfg /home/sasikala/cfg/
A    /home/sasikala/cfg/ftp_user.cfg
A    /home/sasikala/cfg/inventory.cfg
A    /home/sasikala/cfg/email_user.cfg
A    /home/sasikala/cfg/svn-commands
Checked out revision 811.

$ ls /home/sasikala/cfg
.  ..  .svn  email_user.cfg  ftp_user.cfg  inventory.cfg  svn-commands

When you do a checkout, it creates hidden directory named .svn, which will have the repository details.

2. SVN Commit – Save changes to the repository

Whenever you do changes to the working copy, it will not reflect in SVN server. To make the changes permanent, you need to do SVN commit.


$ svn commit -m "log messages"

Explain why you are changing the file in the -m option.

For example, in my working copy, the file named “svn-commands” has the following content.

$ cat /home/sasikala/cfg/svn-commands

$ ls -l /home/sasikala/cfg/svn-commands
-rw-r--r--  1 root root 41 Apr 16 11:15 svn-commands

I made a change in this file (for example, making this file empty).

$ ls -l svn-commands
-rw-r--r--  1 root root 0 Apr 16 11:20 svn-commands

Now commit the file to make the changes permanent in the server.

$ svn commit -m "Making the file empty" svn-commands
Sending        svn-commands
Transmitting file data .
Committed revision 813.

After this whenever you update your working copy or checkout, the changes will appear in the server.

3. SVN List – Lists directory entries

svn list is useful when you want to view the content of the SVN repository, without downloading a working copy.


$ svn list

The following example lists all the files available in the given URL in the repository without downloading a working copy. When you execute svn list command with –verbose option it displays the following information.

  • Revision number of the last commit
  • Author of the last commit
  • Size (in bytes)
  • Date and time of the last commit
$ svn list --verbose https://www.thegeekstuff.com/project/branches/release/migration/data/bin
 16 sasikala	28361 	Apr 16 21:11 README.txt
 21 sasikala 	0 	Apr 18 12:22 INSTALL
 22 sasikala		Apr 18 10:17 src/

4. SVN Add – Add a new file to SVN repository

When you want to add a new file (or directory) to the repository you need to use SVN add command. The repository will have newly added file, only when you do SVN commit. Now let us add a new file called “thegeekstuff” to our repository.

  • Create a file in local working copy
  • $ ls -l /home/sasikala/cfg/thegeekstuff
    -rw-r--r--  1 sasikala root 8 Apr 16 11:33 thegeekstuff
  • Add the file into SVN repository
  • svn add filename will add the files into SVN repository.

    $ svn add thegeekstuff
    A         thegeekstuff
  • Commit the added the file
  • Until you commit, the added file will not be available in the repository.

    $ svn commit -m "Adding a file thegeekstuff" thegeekstuff
    Adding         thegeekstuff
    Transmitting file data .
    Committed revision 814.

5. SVN Delete – Removing a file from repository

SVN delete command deletes an item from the working copy (or repository). File will be deleted from the repository when you do a SVN commit.

$ svn delete URL

Now let us remove the recently created file called “thegeekstuff”.

$ svn delete thegeekstuff
D         thegeekstuff

$ svn commit -m "Removing thegeekstuff file" thegeekstuff
Deleting       thegeekstuff
Committed revision 814.

Now you can do svn list and check whether the file was deleted from the repository.

6. SVN Diff – Display the difference

SVN diff displays the differences between your working copy and the copy in the SVN repository. You can find the difference between two revisions and two paths etc.,

$ svn diff filename

$ svn -r R1:R2 diff filename

The above example compares the filename@R1 and filename@R2.

Now the content of the file thegeekstuff looks like this,

$ cat /home/sasikala/cfg/thegeekstuff

I edited the content of thegeekstuff file from testing to tester, which is shown below using the svn diff command.

$ svn diff thegeekstuff
Index: thegeekstuff
--- thegeekstuff   (revision 815)
+++ thegeekstuff   (working copy)
@@ -1 +1 @@

7. SVN Status – Status of the working copy

Use svn status command to get the status of the file in the working copy. It displays whether the working copy is modified, or its been added/deleted, or file is not under revision control, etc.


$ svn status PATH

The following example shows the status of my local working copy,

$ svn status /home/sasikala/cfg
M    	/home/sasikala/cfg/ftp_user.cfg
M      	/home/sasikala/cfg/geekstuff

‘M’ represents that the item has been modified. “svn help status” command will explain various specifiers showed in SVN status command.

8. SVN Log – Display log message

As we discussed in the beginning of this article, SVN remembers every change made to your files and directories. To know all the commits made in a file or directory, use SVN log command.


$ svn log PATH

The following displays all the commits made on thegeekstuff file

$ svn log thegeekstuff
r815 | sasikala | 2011-04-16 05:14:18 -0700 (Sat, 16 Apr 2011) | 1 line

Adding a file thegeekstuff

Since we made only one commit in the file thegeekstuff, it shows only one log message with the details.

9. SVN Move – Rename file or directory

This command moves a file from one directory to another or renames a file. The file will be moved on your local sandbox immediately (as well as on the repository after committing).

$ svn move src dest

The following command renames the file “thegeekstuff” to “tgs” in a single stroke.

$ svn move thegeekstuff tgs
A         tgs
D         thegeekstuff

$ ls
.#  ..  .svn  email_user.cfg  ftp_user.cfg  inventory.cfg  tgs

Now the file is renamed only in the working copy, not in the repository. To make the changes permanent, you need to commit the changes.

$ svn commit -m "Renaming thegeekstuff to tgs" tgs
Adding         tgs
Transmitting file data .
Committed revision 816.

10. SVN Update – Update the working copy.

svn update command brings changes from the repository into your working copy. If no revision is specified, it brings your working copy up-to-date with the HEAD revision. Otherwise, it synchronizes the working copy to the revision given in the argument.

Always before you start working in your working copy, update your working copy. So that all the changes available in repository will be available in your working copy. i.e latest changes.


$ svn update PATH

In case some other user added/deleted file in URL, https://www.thegeekstuff.com/project/branches/release/migration/data/cfg, your working copy will not have those files by default, until you update your working copy.

$ svn update
A  new/usercfg
A  new/webcfg
Updated to revision 819.

In the above svn update command output, A represents that this file is “Added” to the working copy.

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 15 comments… add one }

  • Sergio April 25, 2011, 1:07 am

    I would also like to point out the following option:
    “svn switch –relocate FROM TO”

    If you were working in your repository and somebody ( like in my case) changes the port you were working with , you won’t be able to commit new changes, consult your logs, or whatever. This command sorts this out.

    Nice post !

  • BalaC April 25, 2011, 9:09 am

    May be a post on GIT as well will be very helpful.

  • Mike Stewart April 25, 2011, 10:22 am

    git / bazaar / mercurial to svn integration would be useful.

    but really, anyone locked into SVN is likely already locked into a standardized workflow.

  • narcis April 26, 2011, 6:08 am

    My favorite update command:
    svn update svn+sshtunnel://user@server/home/svn/repos svn/

  • Glenn October 13, 2011, 1:33 pm

    Late to the party here…

    If I make a change to my working copy and I want to do a commit, do I have to tell the server what file to update implicitly? IE, subversion won’t do a scan and compare of all the files and sync the different files in the same manner as a program such as “Unison”?

  • Milind June 22, 2012, 3:40 pm

    If I add a new directory and add new files to that directory, is there a way to commit the new directory and the files in it ? If not, what should be the correct steps ?

  • ravi June 27, 2012, 9:01 am

    hi ,

    i want to co the code with out .SVN folder to my working copy?what i want to do?

  • dominic July 9, 2012, 3:07 am

    @Milind this command goes through your local version and adds any new files/directories ready for the next commit:
    svn st | grep “^\?” | awk “{print \$2}” | xargs svn add $1

    @ravi the best way to do this, in my opinion, is using the svn export command

  • jm August 9, 2012, 12:02 am

    great post for novices!

  • Balaji October 26, 2012, 3:20 am

    Hi sasikala ,

    It is a nice post and very useful to beginners .

  • av March 15, 2013, 10:56 am

    very useful — brief and concise… thanks

  • waterlovinguy July 24, 2013, 9:31 pm

    svn status -q
    It will list all the files that have changed, but not list all the un-versioned files. If you have a bunch of crap laying around (big finger pointing at me) it can be much nicer to see only versioned changes listed when you svn status.

    also svn changelist
    Can be quite handy with multiple commits on the command line
    svn changelist NAME_OF_LIST A.file B.file C.file
    svn commit –changelist NAME_OF_LIST

  • Aruljothi September 4, 2013, 4:45 am

    Thanks lot for sharing nice tuts about svn commands in depth information….

  • pandiyan December 31, 2014, 6:51 am

    I have been trying to install svn on my centos 6.6

    all the steps are ran succesfully…but i cant get the output that is

    when i enter the repository url in browser it will display

    when i enter the repository URL that is “http://svn.demo.com/svn/”

    it’ll display


    Not Found The requested URL /svn was not found on this server.

    Apache/2.2.15 (CentOS) Server at Port 80


    …plsease help me friends…and

    my “/etc/httpd/conf.d/subversion.conf” file contain

    Code: LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so

    Example configuration to enable HTTP access for a directory
    containing Subversion repositories, “/var/www/svn”. Each repository
    must be both:

    a) readable and writable by the ‘apache’ user, and

    b) labelled with the ‘httpd_sys_content_t’ context if using


    To create a new repository “http://localhost/repos/stuff” using
    this configuration, run as root:

    # cd /var/www/svn
    # svnadmin create stuff
    # chown -R apache.apache stuff
    # chcon -R -t httpd_sys_content_t stuff


    DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName “SVN authentication required” AuthUserFile /etc/svn-users Require valid-user CustomLog logs/svn_logfile “%t %u %{SVN-ACTION}e” env=SVN-ACTION


  • karthik February 20, 2015, 4:16 am

    i have a shell script, it is used for checkout(Checking out code from SVN repository) and my problem is, while running this code it is asking password at the end and there is no password variable declared inside the script and i need to make that script in such a way that it should not ask password..please provide me solution.

Leave a Comment