SVN
Article Directory
1. Introduction to SVN
- The full name is Subversion, which is a code version management tool
- Can remember every modification
- View all modified records
- Restore any historical version
- Recover deleted files
Two, SVN advantage
- Simple to use and quick to get started
- Directory-level permission control, security
- Can operate on subdirectories (Git can only operate on the entire warehouse)
Three, a few basic concepts
- checkout (check out): download the content of the server to the local, this command only needs to be used once when interacting with the server for the first time
- update: synchronize the new content in the server to the local
- commit (submit): After the content in the local is modified, submit it to the server
- Repository: The location where the source code is stored in the server, and the history of each modification
Four, SVN download and installation
- Download the SVN client installation package from the official website
- Download the Chinese package from the official website
- Download the SVN server installation package from the official website
- Install the above three installation packages
Note: When installing the SVN client, you need to check the corresponding content at this step (the compiler can be integrated with SVN)
- Use the right mouse button at any location, the following content appears, indicating that the installation is successful
Five, SVN configuration and use
- Enter the VisualSVN server, click the following in the interface to configure
- The value of Server name can be set as:
(1) 127.0.0.1 (can only be accessed locally)
(2) Computer user name (can only be accessed locally)
(3) Current IP address (all users who can ping this IP can access)
- New account, password
- New group
- New repository
- Import the project into the server's repository (import)
(1) The address of the copy server warehouse
(2) Select the project in the disk that needs to be uploaded to the server
(3) Paste the address copied in the first step to the corresponding location
(4) Choose to accept permanently
(5) Enter the account and password of the user created above, indicating that this is the zhangsan user importing the project to the server
(6) Import completed
(7) View the imported project after refreshing in the SVN server
- Synchronize the items in the server to the local for the first time (checkout)
(1) Copy the address of the project to be synchronized in the server
(2) Create a directory on the disk to store the items synchronized from the server, right click on the blank space of this directory
(3) Enter the remote address and set the output directory of the project
(4) The checkout is complete, and there are corresponding items in the server in the disk
- Submit the locally modified content to the server (commit)
(1) Create a new hello.txt file locally, right-click this file twice
(2) Select the file to be submitted
(3) The submission is successful, and the newly added content in the local is successfully synchronized in the server
- Synchronize the new content in the server to the local (update)
(1) Right-click on a blank space in the local disk
(2) Successful update
Six, the description of the SVN icon
- General icon
This icon is displayed when the local file is exactly the same as the server file
- Conflict icon
This icon is displayed when the file submitted locally conflicts with the server-side data
- Delete icon
When the server-side data has been deleted, this icon is displayed
- Add icon
When the newly added file locally has been added to the submission queue, this icon is displayed
- No version control icon
When the newly added file is not added to the upload queue, this icon is displayed
- Edit icon
When the local file has been modified but not submitted, this icon is displayed
- Read only icon
When the local file exists in read-only form, this icon is displayed
- Lock icon
When the server-side data is locked, this icon is displayed
- Ignore icon
When the local file has been ignored and does not need to be submitted for upload, this icon is displayed
7. Introduction to conflict issues
- Causes of conflict
Suppose that both users A and B update the hello.txt file when the version number is 100. User A submits hello.txt to the server after the modification is completed. The submission is successful. At this time, the version number of the hello.txt file is It has become 101; at the same time, user B makes modifications on the hello.txt file with version number 100. When the modification is completed and submitted to the server, the submission fails because it is not the modification made on the current 101 version; at this time User B updates the file. If user B and user A modify the same line of code in the file, there will be a conflict
- Conflict file existence form
The conflict file hello.txt will derive the following four files:
(1) The last version hello.txt.r100
(2) Others have submitted an updated version hello.txt.r101
(3) My own updated version hello.txt.mine
(4) The conflict file itself hello.txt
After the conflict is resolved, only hello.txt will remain after the conflict is resolved
- Simulate conflict scenarios
(1) Execute the update command on the local disks of users A and B to update the content to the latest
(2) The original content of the hello.txt file is as follows
(3) User A modifies hello.txt and commits to the repository
(4) User B modifies hello.txt and commits to the repository
(5) The following error occurs when user B commits to the server
(6) User B should execute the update command to update the version, obtain the four derivative files of the conflicting file and resolve the conflict
8. Resolution of conflicts
- User B executes the update command in the project directory on the disk
-
The following files appear in the project directory of user B
-
Right click on the conflicting file
- Pop-up editing conflict window
- If you want to use the server version, right-click in the Theatre window and select Use this text block; if you want to use the local version, right-click in the Mine window and select Use this text block; the final selection will be saved in the merge window
- After the modification is completed, proceed as shown in the figure below to resolve the conflict
-
After the conflict is resolved, only the files after the conflict are resolved, and the derived files disappear automatically
-
User B executes the commit operation again and can submit to the server
Note: Frequent commit and update can reduce the probability of conflicts