This is my experience in the whole process of completing the after-school experiment assignment of software project and process management. I hope it will be helpful for you to use SVN for the first time.
Software project and process management is a course that I only studied when I was a junior in my major,. Before the experiment class, I had no contact with version management tools except for the initial use of GIT. In the first few minutes of the course, the teacher gave us a brief introduction of SVN, and then gave us the experimental guide book and a Java practice development tool document that the teacher had written, so that we could learn the content and complete the experimental report. In the process, the steps in the experimental instruction are not detailed, which leads me and other students not to learn the configuration method and basic operation method of SVN well. Therefore, I began to search for answers on the Internet, but most of the related blog articles are not detailed enough and difficult to understand. After several search and try, I finally completed the most basic operation.
Introduction to version control and SVN
Version control, originally from the field of engineering design, is a standard practice for maintaining engineering blueprints. It can track the process of Engineering blueprints from birth to finalization. It is a system for recording the changes of several documents so as to refer to the revision of specific versions in the future. Subversion is a version control tool software, usually also known as version controller, SVN for short. Subversion is a project organized by the Apache Software Foundation.
- How SVN works
Svn adopts the client / server (C / s) mode — save all versions of project files in the server version library, and all programmers participating in collaborative development save a working copy on their own local computer, which can be in any file format, code, file or picture. The SVN support program updates the local copy to the latest version on the server side, as well as the latest version of the local copy to the server side, and records the version number. Moreover, the later update does not overwrite the previous update version, but is saved as a new version — SVN even supports restoring the local working copy to a historical version saved on the server side.
Server refers to a program on the subversion server side; the program accepts the request from the client and responds; the data is saved in SVN repository
- Basic operation of SVN
Checkout: download the whole project created by a server to the local. This is the first step to participate in the development after arriving at the project team, which only needs to be executed once.
Update: update the local file to the latest version on the server side, usually once before the start of work or before modifying the public file.
Commit: commit local changes to the server. It is usually performed once for every work completed or every function and class hour completed.
Installation and configuration of subversion
- Download and install
Apache-subversion-1.10.2 official download address: https://www.visualsvn.com/dow
After downloading, extract it to the installation directory. For example, I put it in D: Homework software process and project management experiment 2, subversion and TortoiseSVN experiment apache-subversion-1.10.2
- To configure
Next, we need to configure the variable environment to enable SVN.
Find the path in the system variable, and add the variable value: D: Subversion and TortoiseSVN experiment apache-subversion-1.10.2bin
PS: this variable path is the path to the bin folder in the file directory after decompression. The advantage of configuring environment variables is that we can run executable programs in the bin folder in any directory on the command line.
- Configuration check
We can do this by typing
svn --versionTo verify that the SVN environment variables are configured correctly. Display the SVN version information as shown in the figure below, which means that the environment variable configuration is successful.
In addition to version information, it also shows some version library access modules that can be used
So far, we have only configured the server server of SVN. To make SVN work, we need to create a repository of SVN to store the submitted data.
Create SVN version Library
I create d: \ svnrep on disk D. svnrep is the root directory of the local version library. We hope that svnrep can help us manage multiple projects. So we create different folders in the svnrep directory, such as OA and ERP I created, as repositories for multiple projects. But at this time, the folder I created is not connected to the server, so we need to enter some instructions under the command line window to complete this operation. We open the command line and use 'svnadmin create d: \ svnrep \ CRM' to connect the version library to the server. ! [picture description]  The path after create is the path of the root directory of the version Library At this time, there will be some more files in the D: \ svnrep \ CRM directory. As shown in the figure below. ! [picture description]  The conf file is the configuration file related to the current version. Later, when we set the permissions of the version library, we will use the files in it. The DB file is the database file of the server. The hooks program (related operation triggers) is stored in hooks. The locks are related to the locking of files
Start SVN server
To run the client, we need to enter the command ` svnserve - D - R D: \ svnrep \ CRM` ! [picture description]  At this point, the command line no longer allows you to enter instructions, indicating that the server has started We can confirm whether the service is started by checking whether it listens to the port of 3690. In the other command line, enter the following instruction netstat - an to find the address with the suffix of 3690. If it exists, it indicates that the service is started. ! [picture description]  We can see the local address with tail number 3690 as shown in the figure
- Register for Windows Services
Since the command line window that starts the server is in the first command line window, once the command line window is closed, the service stops. In practice, it is inconvenient for us to keep the command line window open all the time, so we can register the SVN server program as a Windows service and let the SVN service start with the system.
The steps are as follows:
Step 1 start computer – > Management – > services and Applications
There are many services in the service that can be enabled automatically or manually
Step 2 reopen a command line window and enter the command
SC create svnservice binpath = "D: \ assignment \ software process and project management experiment class \ Experiment 2 subversion and TortoiseSVN experiment \ apache-subversion-1.10.2 \ bin \ svnserve.exe -- Service - R D: \ svnrep" start = auto depend = TCPIP
The reason why the specified version library is svnrep is that when we access it, we can decide to visit a specific warehouse under svnrep.
After this instruction is executed, the command line may pop up the prompt of windows OpenSCManager failure 5 to deny access. This is because we do not have sufficient permissions to create new services. There are two solutions. The first is to run the command line as an administrator, and the second is to run the command line in the registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUAChange its value to 0.
The prompt content of creating success is shown in the following figure.
At this point, we can pass it again
netstat -anTo see if there is a local address for 3690.
Client access and operation of three basic commands of SVN
Next, we enter the operation of three basic commands of SVN. I created two workspace folders under the directory D: \ workspace \ workspacesvn, which are the folders for spacea and spaceb, representing the working codes of the two members. We will check out, update and submit the files in the two workspace folders through SVN. Enter the command 'SVN checkout SVN: // localhost / CRM' in the command line. Since we are now deploying SVN's server on the local server, it is localhost.
This step is performed in the directory of spacea, so we download the files from the server library to spacea. However, there are no files in the current server version library, so the files are still hot in spacea. After the command is executed, the command line prompts to check out version 0. Next, we create an svn_test.txt file under the CRM of spcaea. Submit this file in the directory spacea \ CRM \ CRM. The command entered in the command line is' SVN commit svn'test.txt '. After execution, the command line may prompt that the commit fails.
The reason is that at the time of initial submission, the submitted documents are not under version control. So we’re going to type it on the command line
svn add test.txt.
Next, we enter
svn commit svn_test.txt, the command line may still prompt for errors after execution.
The reason is that we should also add logs when we commit. So, on the command line, we type
svn commit -m "My first commit" svn_test.txt, but the command line may still prompt for errors.
This is due to insufficient permissions. Therefore, we need to set permissions in conf of the version library. Open svnserve.conf in D: \ svnrep \ CRM \ conf to change "anon access = read" to "anon access = write". Note: there must be no spaces before Annon access. After modification and saving, enter 'SVN commit - M "my first commit" svn_test.txt "in the original command line again. The prompt is as follows, that is, commit succeeded.
The version number after the prompt is 1, which refers to the version number of the current version of the entire version library instead of the version number of each file.
We then use the command line to commit the file from the repository to spaceb.
Next, let’s update the version library file.
Modify the contents of svn_test.txt in spaceb. As shown in the figure below.
After that, commit the modified svn_test.txt to the version library. As shown in the figure below.
The submitted version number is 2
Next, we go to CRM in spacea. We update svn_test.txt in CRM through command line instructions
svn update svn_test.txt
At this point, we can find that the content of svn_test.txt in spacea has been updated.