Introduction and use of SVN

1. Introduction to SVN:

Subversion(SVN) is an open source version control system, that is, subversion manages data that changes over time. This data is placed in a central repository. The archive is much like an ordinary file server, but it remembers every file change. In this way, you can restore the file to the old version or browse the change history of the file.

Some basic operations of SVN:

  • repository (source code base)  : Where the source code is stored uniformly
  • Checkout (extract)  : When you don't have the source code, you need to check out a copy from the repository
  • Commit  : When you have modified the code, you need to commit to the repository
  • Update  : When you have checked out a copy of the source code, you can synchronize with the source code on the Repository after updating, and the code in your hand will have the latest changes

The daily development process is actually like this (assuming you have checked out and worked for a few days): update (get the latest code) - > make your own modifications and debug successfully -- > commit (you can see your modifications).

Main functions of SVN

  • (1) Directory version control

    CVS can only track the history of a single file, but Subversion implements a "virtual" version control file system that can track the changes of the entire directory over time. Both directories and files can be versioned.

  • (2) Real version history

    Since CVS limits the version record of files, CVS does not support operations that may occur on files but affect the contents of the directory, such as copying and renaming. In addition, in CVs, you cannot replace a file that has been incorporated into the system with a file with the same name but does not inherit the old version history or has no relationship at all. In Subversion, you can add, delete, copy, and rename files and directories. All new files start with a new, clean version.

  • (3) Auto submit

    A submission action is either completely updated to the archive or not completely updated. This allows developers to create and submit changes in logical intervals to prevent problems when partial submissions are successful.

  • (4) Metadata included in version control

    Each file and directory is attached with a set of attribute keywords and associated with attribute values. You can create and store any Key/Value pair you want. Properties are versioned over time, just like file content.

  • (5) Select different network layers

    Subversion has an abstract concept of file inventory retrieval, which makes it easy to implement the new network mechanism. Subversion can be embedded into the Apache HTTP server as an extension module. This provides subversion with very advanced stability and collaboration capabilities. In addition, it also provides many important functions: for example, identity authentication, authorization, online compression, file library browsing and so on. There is also a lightweight independent subversion server, which uses a custom communication protocol and can be easily used in the tunnel mode through ssh.

  • (6) Consistent data processing

    Subversion uses binary difference algorithm to express the difference of files. It treats both text (human understandable) and binary files (human incomprehensible) equally. Both types of files are stored in the archive in the same compressed form, and the file difference is transmitted over the network in two directions.

  • (7) Valid branches and Tags

    The consumption on branches and labels does not have to be proportional to the project size. Subversion's method of establishing branches and labels is just to copy the project, and the method used is similar to hard link. Therefore, these operations will only take a small and fixed time.

  • (8)Hackability

    Subversion has no historical baggage; It is mainly a group of common C program libraries with well-defined API s. This makes subversion easy to maintain and can be used by other applications and programming languages.

2. SVN server installation:

windows version download link

//Install SVN
[root@localhost ~]# yum install -y subversion

//Create version Library
[root@localhost ~]# mkdir /svn

//Version library initialization
[root@localhost ~]# svnadmin create /svn
[root@localhost ~]# ll /svn/
Total consumption 8
drwxr-xr-x. 2 root root  76 10 December 10:52 conf
drwxr-sr-x. 6 root root 233 10 December 10:52 db
-r--r--r--. 1 root root   2 10 December 10:52 format
drwxr-xr-x. 2 root root 231 10 December 10:52 hooks
drwxr-xr-x. 2 root root  41 10 December 10:52 locks
-rw-r--r--. 1 root root 246 10 December 10:52 README.txt

//Profile directory
[root@localhost ~]# cd /svn/conf/
[root@localhost conf]# ll
total 20
-rw-r--r--. 1 root root 1080 Oct 12 00:56 authz
-rw-r--r--. 1 root root  885 Oct 12 00:56 hooks-env.tmpl
-rw-r--r--. 1 root root  309 Oct 12 00:56 passwd
-rw-r--r--. 1 root root 4375 Oct 12 00:56 svnserve.conf
#authz: control permissions
#passwd: password file
#svnserve.conf: warehouse configuration file

//Configure users and permissions
admins = user1             #admins:Group name #user1: user

[/]			               #[/]: specify the directory, "/" represents the root directory of the warehouse, i.e. / data/svnroot/myproject/
@admins = rw	       	   #Specify a the permissions corresponding to the dmins group for configuring user passwords

//Configure user password
[root@localhost conf]# vim passwd
user1 = 123456

//Configure warehouse file
[root@localhost conf]# vim svnserve.conf
anon-access = none  		#Specify anonymous user permissions
auth-access = write  		#Specify authenticated user permissions
password-db = passwd		#Specify user password file
authz-db = authz			#Specify user rights file
realm = /svn				#Specify the warehouse file to use (absolute path)

//Start SVN
[root@localhost conf]# svnserve -d -r /svn

//View 3690 port
[root@localhost conf]# ss -antl
State     Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process    
LISTEN    0          128            *
LISTEN    0          128              *
LISTEN    0          128                     [::]:22                   [::]:*

Keywords: svn

Added by rodin69 on Tue, 12 Oct 2021 09:15:30 +0300