Site icon Narayana Tutorial

SVN Commands in Linux

svn

This article helps you to understand various SVN commands and its usage in Linux environment.

How To get the location of SVN:

$ whereis svn
svn: /opt/CollabNet_Subversion/bin/svn

(or)

$ which svn
svn: /opt/CollabNet_Subversion/bin/svn

How to get the SVN help

$ svn help
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.8.14.
Type ‘svn help <subcommand>’ for help on a specific subcommand.
Type ‘svn –version’ to see the program version and RA modules
or ‘svn –version –quiet’ to see just the version number.Also, lists down all the available options

How to get the SVN info

$ svn info
Path: .
Working Copy Root Path: /home/<username>/<svn_project>
URL: <svn repository url>
Relative URL: ^/<svn relative url>
Repository Root: <svn root>
Repository UUID: <>
Revision: <revision#>
Node Kind: directory
Schedule: normal
Last Changed Author: <username>
Last Changed Rev: <revision#>
Last Changed Date: <Date and time>

How To Check out a code from SVN repository:

$ svn checkout <svn url>

or

You can create a directory to check out the code there

$mkdir project

$ svn checkout <svn url> project

How To Check in or commit the code into SVN repository:

$svn commit file1, file2, file3

or

You can commit a directory as well

$svn commit folder_name

Note: If the file or folder is new that has to be added into svn prior commit

$svn add file1, file2, file3

or

You can add a directory as well, which adds all the files inside the directory

$svn add folder_name

How to get the log from SVN:

$ svn log -l 10
This list down last 10 log history

How to perform SVN update:

$ svn update

This will update the svn project repository to the head revision

A – Added

U – Local file or directory Updated

M – Merged

D – Deleted

 

How to get the SVN status:

$ svn status
This list down all the files which are modified or new or removed from repositoryM – Modified? – New file or folder

! – Removed from repository

A – Added to the repository

U – Local file or directory Updated

How to unlock the locked SVN project:

$ svn cleanup

or

$svn unlock

The svn project is unlocked

How to revert the local changes in the SVN project:

First try to get the details of modified files in the project using $svn status

$ svn revert file1, file2….

Local changes will be reverted to the svn revision

 

How to overcome the issue – File is not under version control:

This issue may occur when you try to commit the file which was not added to the svn. For instance, there is a file(test1) added in your project and you are trying to commit the test1 file into svn.

$ svn commit test1

The test1 is not under version control.

Now, add the file into svn using $svn add test1 and then perform commit

How to Switch the user that has been used for code checkout

 

Assume the svn project is being checked out by user1 and that needs to be switched to user2.

$svn update –username=<user2>

or

$svn update –username <user2>

How to rename a file or directory which is in SVN repository

Assume file1 is exists in SVN repository and that needs to be changed to file2.

$ svn move file1 file2
or

Aliases: mv, rename, ren

$svn mv    or    $svn rename    or    $svn ren

Please find the svn help snapshot

-bash-4.1$ svn help
usage: svn <subcommand> [options] [args]
Subversion command-line client, version 1.8.14.
Type ‘svn help <subcommand>’ for help on a specific subcommand.
Type ‘svn –version’ to see the program version and RA modules
or ‘svn –version –quiet’ to see just the version number.Most subcommands take file and/or directory arguments, recursing
on the directories. If no arguments are supplied to such a
command, it recurses on the current directory (inclusive) by default.Available subcommands:

add
blame (praise, annotate, ann)
cat
changelist (cl)
checkout (co)
cleanup
commit (ci)
copy (cp)
delete (del, remove, rm)
diff (di)
export
help (?, h)
import
info
list (ls)
lock
log
merge
mergeinfo
mkdir
move (mv, rename, ren)
patch
propdel (pdel, pd)
propedit (pedit, pe)
propget (pget, pg)
proplist (plist, pl)
propset (pset, ps)
relocate
resolve
resolved
revert
status (stat, st)
switch (sw)
unlock
update (up)
upgrade

Subversion is a tool for version control.
For additional information, see http://subversion.apache.org/

SVN Help Command

Please leave a comment for any SVN issues or assistance in resolving the same.