SVN Intro – Branching & Merging

We will create the SVN REPO using the

  • #svnadmin create   – @SVN Server

Now create 3 directory called Trunk, Branches, Tags

The working code is initially placed in the TRUNK dir

  • #vim
  • abc 123
  • #svnserve -d

[Note: now a user abc with password 123 is created.]


  • #telnet 3690
  • #svn co svn:// #cd #mkdir trunk branches tags
  • #svn add * #svn commit -m “Added  branch tags trunk”
  • #svn import ../repo/common/dbbackup svn:// -m “Adding Code to Trunk”
  • #svn cp svn:// svn:// -m “Giving Code to Developer sanoob”
  • #svn cp svn:// svn:// -m “Giving Code to Developer Ammukutty”
  • #svn cp svn:// svn:// -m “Placing Code on Production”

@Sanoob’s Machine

  • #svn co svn://
Creating a New File (Hi.txt), modifying and Commiting it.
  • #echo Hiiiiiiiiiiiiiii > Hi.txt
  • #svn add Hi.txt
  • #svn ci -m “Deleted all and added Hi”

[NOTE: After editing a file an “SVN CI” has to be made to reflect the same on the Central Repo]

  • #svn status         – to know the added,modified or deleted status – Mostly applied to Dev Machines #echo rev2 unni > Hi.txt
  • #svn ci -m “changes to Hi.txt”

On a different machine where the checkout is already done then , the following command will update the status.

  • #svn up Hi.txt   – restore the status to a revision number latest in according to svn repo @ svn server

[NOTE: “SVN INFO” will show an updated Revision Number only if “SVN UP” is done]

To revert to a revision

  • #svp up -r 7             – Mass Updating


  • #svp up [filename] -r 7  – Only one file is Updated

@Ammukutty’s Machine

  • #svn co svn://

@Production Server – always use “SVN UP”…….and never “SVN CO”

To DELETE a file both locally & repo simultaneously –  @ PRODUCTION SERVER

  • #svn delete testdir
  • #svn ci -m “Deleted testdir “

SVN Merging – @Sanoob (NOT applicable to merge multiple developers code)

  • #svn switch svn://
  • #svn up
  • #svn merge svn:// svn://
  • #svn ci -m “Merged Production with sanoob”

SVN Merging – @Production

  • #svn merge -r<NO1.>:<NO2.> path/of/developers/trunk


NO1. – revision number of current project – PRODUCTIONS – “Last Changed Revision”
NO2. – revision number of developer project – “Last Change Revision”

More Info

SVN Directory Structure
/trunk – Development sandbox for standard scenarios
/branches – Long Isolated work; Major Structural Changes
/tags – Stable, Numbered Versions Ready for Release

SVN Status –
!  – a file is deleted locally when compared to SVN Repo
A – a file is added to SVN Repo
U – a file is updated
C – a file conflict

SVN Starter


To Install SVN
#apt-get install subversion

To Create the SVN Repo
#svnadmin create

Under / you will find repository configuration files, interesting for us at the moment are only passwd and svnserve.conf.

Edit the SVN Configuration File
#vim conf/svnserve.conf

Edit also the svnserve.conf to have following contents:
anon-access = none
auth-access = write
password-db = passwd

Add the SVN User to the SVN
#vim conf/passwd

For testing edit the passwd file to have following contents
Entry: unni = 123unni

Notice that the password will be written in clear-text in this file, so for security reasons you might want NOT to use the same credentials as you use in your system as a login account (although if you make sure with chmod 600 passwd that only the user svnowner can access the file, the risk of someone being able to sneak a peak without administrative account or knowing the svnowner password is minimal).

Start SVN Server
#svnserve -d

[NOTE: SVN Port – 3690]


Make sure you have svn client tools installed on your computer. In command line issue:

If its for an already existing project say then to enable SVN for this Project,

Upload all the source code to the SVN Repo Initially

#svn import svn_monitored_dir svn://IPofSVN_CentralRepo:Location_of_SVN_repo@SVN_Svr
#svn import public_html svn://

AND, Bring down the first Check Out as Revision 1

#svn co svn://IPofSVN_Central_Repo:Location_of_SVN_Repo_ at_SVN_svr local_dir
#svn co svn:// publicunni

ADD a New file and COMMIT IT
#cd [to the SVN Monitored Dir]
#echo “I am a Test” > test.txt
#svn add test.txt        [To add a bunch of files – #svn add *]
#svn ci -m “Commit test”

To get current SVN Revision Number
#svn info

To Update to Latest Changes
#svn up

To List the Modified Files
#svn status