SVN is the abbreviation of subversion. It is an open source version control system. It is characterized by centralized management, that is, one trunk branch and multiple local branches. Only one user can commit at a time, which is suitable for small and medium-sized projects and is convenient and fast.
1, SVN server setup
#svn installation yum -y install subversion #Check whether the installation is successful svnserve --version --The following command needs to be used again----------------------------------------------- #Check the svn installation path (you can check it if you are interested) rpm -ql subversion # Set startup svn server systemctl enable svnserve # Turn off and start svn server systemctl disable svnserve
2. Create svn root directory and project warehouse
# Create svn root mkdir -p /data/svn # Create the first project warehouse directory, project1 mkdir -p /data/svn/project1 # Create svn project1 project version repository svnadmin create /data/svn/project1
Enter / data/svn/project1 to view:
3. Configure the warehouse management information of project1 project and enter the conf directory first
1) Modify the svnserve.conf file. Just open the following comments
anon-access = none #Anonymous user readable auth-access = write #Authorized user writable password-db = passwd #Which file is used as the account file authz-db = authz #Which file is used as the permission file
2) Modify the passwd file and add users, such as:
3) Modify authz files and manage user permissions, such as:
[groups] Group management authority, flexible use of section, convenient management of users
[repository:/baz/fuz] Where repository can be omitted, [Repository: /] or [/] represents the root directory of the project warehouse, and [/ foo/bar] represents the / foo/bar directory under the warehouse. You can configure multiple directory management permissions to manage permissions for different directories.
PS: for all configuration files, there must be no space at the front of each configuration, and the import is edited under centos. The coding is different under windows.
4. Open svn server version Library:
# Description: - d daemon- r followed by the root directory of the version library svnserve -d -r /data/svn --listen-port=3690 # Check whether svn is started successfully netstat -antlp | grep svnserve
PS: it should be noted that / data/svn is the root directory of the svn server version library and does not involve specific projects, because svn manages all project warehouses under it by sensing this root directory.
5. Open port
firewall-cmd --zone=public --add-port=3690/tcp --permanent firewall-cmd --reload
2, Upload code using svn client
If you need to upload the desired project to the version library, you can use the import command. Shown here is an empty directory to create a file and submit it
1. Pull directory
# Create a directory to pull items mkdir -p /data/svnTest cd /data/svnTest # Pull the content in the version Library # Method 1: the root directory is project1 svn co svn://127.0.0.1/project1 --username zgq --password 123456 --non-interactive or # Method 2: the root directory is project1_1, replacing the project1 name in the version library svn co svn://127.0.0.1/project1 project1_1 --username zgq --password 123456 --non-interactive
First use method 1 and use the default directory.
2. Enter / data/svnTest/project1, create some content and submit:
The contents are: a main.c file, a design directory, and an item.lua file in the design directory
Submit to the project version Library (return to project1 directory):
# Incorporate documents and directories into version control svn add * # The user name and password are set in the previous checkout, which is generally not used here. If necessary, add the same parameters, or wait for the prompt before entering # Prompt the authentication domain plaintext, and type yes. # svn commit ./* -m "first commit" [--username zgq --password 123456 --non-interactive]
If the following error is reported, please check whether svnserve.conf and other configurations require modification. Restart after modification, that is, kill the process (through ps aux | grep Svnserve finds the process id and executes svnserve - D - R / data / SVN -- listen port = 3690)
So far, the svn client has pulled the project and submitted the new content introduction. Readers can pull another directory for further operation and enter the command of svn.
svn related instructions can be used in any checkout project. All commands of svn client can be viewed through svn help. For specific commands, you can use svn help cmd, such as svn help add. Get used to using help to view the detailed manuals of various commands, which helps to master the svn command line operation more easily.