Posts Tagged ‘Linux:subversion basic commands’

Linux SVN/Subversion Usefull commands

Thursday, February 25th, 2010

Ref:http://svnbook.red-bean.com/en/1.5/svn.tour.cycle.html#svn.tour.cycle.update

(A) How to install and Import directory into repository:
Click here

(B)How to get working copy from svn repository into local machine?
Goto Your home directory , example : cd /root
Now execute bellow commands

[root@mail ~]# svn checkout file:///svn
A    svn/script
A    svn/script/checkmemory.sh
A    svn/config
A    svn/config/httpd-vhosts
Checked out revision 2.

Now you will see there is a directory call svn has been created in to your home directory and this svn has all the files we added before
Example :

[root@mail ~]# ls
 rpmforge-release-0.3.6-1.el5.rf.i386.rpm
epel-release-5-3.noarch.rpm  script
svn
[root@mail ~]# cd svn
[root@mail svn]# ls
config  script
[root@mail svn]# cd script/
[root@mail script]# ls
checkmemory.sh
[root@mail script]# pwd
/root/svn/script
[root@mail script]#

NOte : If you want to just check out only one directory example script. then command would be :

[root@mail ~]# svn checkout file:///svn/script
A    script/checkmory.sh
Checked out revision 2.

(C) How to get the Updated copy of the working directory

[root@mail script]# svn update
U    checkmemory.sh
Updated to revision 3.
[root@mail script]#

While you are working on a file.if any one changes to that file and you want to download those changes, then svn update will give the up to date file.

(D) How to add directory or file to the repository

[root@mail script]# svn add check_cpu.sh check_memory.sh
A         check_cpu.sh
A         check_memory.sh
[root@mail script]#
 
Note : Dont forget to run bellow command to make the update permanently
svn commit

(E) How to delete file or directory

 [root@mail script]# svn delete check_memory.sh 
D         check_memory.sh

(F) How to view overall changes of local modifications

[root@mail script]# svn status
A       check_ping
M       check_cpu.sh
[root@mail script]#

(G) How to view the details of local modifications

For Every modifications( every files)
[root@mail script]# svn diff
Index: check_ping
===================================================================
--- check_ping  (revision 0)
+++ check_ping  (revision 0)
@@ -0,0 +1 @@
+This is a test insert
Index: check_cpu.sh
===================================================================
--- check_cpu.sh        (revision 4)
+++ check_cpu.sh        (working copy)
@@ -0,0 +1 @@
+This is a test line
[root@mail script]#
 
For a particular file:
 
[root@mail script]# svn diff check_cpu.sh
Index: check_cpu.sh
===================================================================
--- check_cpu.sh        (revision 4)
+++ check_cpu.sh        (working copy)
@@ -0,0 +1 @@
+This is a test line
[root@mail script]#

(H) How to commit changes ( update your working copy with svn repository)

   svn commit

Before committing , it will open vim editor and you need to insert some comments about what you updating for your/Other peoples references.

(I) How to check history ?
Ref :http://svnbook.red-bean.com/en/1.5/svn.tour.history.html

[root@mail script]# svn log
------------------------------------------------------------------------
r5 | root | 2010-02-25 14:10:45 +0000 (Thu, 25 Feb 2010) | 3 lines
 
Added Check_ping file
Modified check_cpu file
 
------------------------------------------------------------------------
r4 | root | 2010-02-25 13:55:01 +0000 (Thu, 25 Feb 2010) | 2 lines
 
Added Check_cpu and Delete check_memory.sh file
 
------------------------------------------------------------------------
r3 | root | 2010-02-25 13:42:52 +0000 (Thu, 25 Feb 2010) | 2 lines
 
Just update
 
------------------------------------------------------------------------
r1 | root | 2010-02-25 11:19:54 +0000 (Thu, 25 Feb 2010) | 2 lines
 
Just Adding a directory
 
------------------------------------------------------------------------

Meaning of A,C,D,M:

A item
 
    The file, directory, or symbolic link item has been scheduled for addition into the repository.
C item
 
    The file item is in a state of conflict. That is, changes received from the server during an update overlap with local changes that you have in your working copy (and weren't resolved during the update). You must resolve this conflict before committing your changes to the repository.
D item
 
    The file, directory, or symbolic link item has been scheduled for deletion from the repository.
M item
 
    The contents of the file item have been modified.