Introduction to SVN:
Why use SVN?
In the process of writing a program, each programmer will generate many different versions, which requires the programmer to effectively manage the code, and can quickly and accurately extract the corresponding version when needed.
What is Subversion?
It is a free/open source version control system. A set of files is stored in a central repository, and every file and directory modification is recorded. Subversion allows data to be restored to an earlier version, or to check the history of data modification. Subversion can pass the network Access its repository, allowing users to work on different computers.
One: SVN server construction and use.
1. First, download and build the SVN server . The download address is as follows : http://subversion.apache.org/packages.html . After entering the URL, scroll to the bottom of the browser to see the following screenshot:
Personally, I think it is best to use the VisualSVN server server and TortoiseSVN client together . Click on the VisualSVN connection above , download the VisualSVN server, and double-click to install after the download is complete, as shown below:
Click Next to next step, as follows:
Then click the Next item, the next step is as follows:
Click【Next】as follows:
Location refers to the installation directory of VisualSVN Server , Repositorys is to specify your repository directory. Server Port specifies a port , Use secure connection Goushan means to use a secure connection ,
Click Next to enter the next step , as shown below :
Then click [ Install] to enter the following installation diagram:
After the installation is complete, click [ next] to enter the next step: as shown below
Click [ Finish] to complete the installation. After the installation is complete , start VisualSVN Server Manager, as shown in the figure :
You can see some information about the repository on the right side of the window , such as status , logs , user authentication , repository, etc.
To create a repository , you need to right-click on Repositores in the left window, as shown below :
In the pop-up context menu, select Create New Repository or New- >Repository:
Go to the next step, as shown below:
Click [Next], as shown below:
Click [ create], as shown below:
Click [ Finish] to complete the basic creation.
2. Users and groups need to be established, and permissions need to be assigned .
1. Right-click the user group on the left side of the VisualSVN Server Manager window and select Create User or New->User, as shown in the figure:
After clicking User, enter the following figure:
After filling in the Username and password, click the ok button to enter the following figure:
After clicking the [ Add] button above, the picture is as follows
Add longen0707 to the user (if there are multiple users, the operation is the same ).
2. Then we create a user group , right-click the user group on the left side of the VisualSVN Server Manager window , and select Create Group or New- >Group, as shown in the figure :
After clicking the [ Group] button, enter the following figure:
Fill in the Group name as Developers in the pop-up window, then click the Add button , select Developer in the pop-up window, join the group , and then click Ok.
Next we need to set permissions for the user group, right-click on MyRepository and select Properties , as shown in the figure :
In the pop-up dialog box , select the Security tab , click the Add button , select longen0707, then add it in , and set the permission to Read/Write, as shown below :
Click the [OK] button.
--------------------Installation and use of the client -----------------
Installation Notes
Developers strongly recommend using the SVN plugin in the IDE to be more intelligent and user-friendly.
First install the SVN client. Windows generally choose the turtle client https://tortoisesvn.net/downloads.html .
Select the corresponding client to install according to the number of system bits.
If you like to use the command line, please remember to check command line client tool
as will be install on local hard driver
, skip this step without the command line.
Then all the way to next can be installed. After installation, right-click anywhere to view the shortcut menu. If found TortoiseSVN
, the installation is successful.
If the installation command line tool is checked, then enter the command SVN, and the following prompt also indicates that the installation is successful
But the menus are all in English at this time. If you are not used to English, you can download the language pack and remember to check the system digits.
After installing the language pack, you can right-click to enter the setting
settings.
Select the language you like (such as Chinese), and then confirm, no accident, the language has now been switched to Chinese.
This is the end of the installation tutorial. Let's start to introduce the use of SVN.
Instructions for use
Check out an item
If the project is already in the server's repository, all you have to do now is to check it out locally.
First create an empty folder. Right-click in an empty folder and select SVN Checkout.
Now you see this interface, fill in the repository address, and select OK.
A dialog box will pop up for you to enter your account password, just enter your account password. Remember to tick Save Authentication, otherwise you will be asked to enter every time you operate.
Check out in a few minutes.
At this point you can see your project in your directory, and now you can start working happily.
import project
But sometimes you have already built a project locally and need to push your project to SVN. What should you do at this time?
Right-click and select Repository Browser.
In the corresponding directory, right-click, add file/add folder, and select the corresponding directory.
。
For example, I now have a project called SVNProject, and I want to upload it to SVN.
Then I just choose to join the folder.
Be sure to enter submission information. So others can know what you did.
After the import is successful, you can see the directory.
However, don't assume that the import is successful and that's it. You have to check out again, the re-checked out project is controlled by SVN, be sure to remember to check out.
Right-click on SVNProject to check out to the local, and then modify it inside. Now you can work happily.
The right-click menu after checking out becomes like this.
submit
Green indicates that the current file has not been modified (restart the computer if you cannot see the color).
Suppose I now 我是新项目.txt
add a line of words in and save it.
The discovery is now red, which means it has been modified.
How to submit changes?
In the root directory, right-click and select Submit.
Be sure to remember to enter the submission information (although you can submit it without entering it), the submission information can be easily viewed in the future.
After the submission is complete, it can be found that it has returned to green.
Suppose now that a new file is added. It can be seen to be blue. Blue indicates unknown files that do not belong to the repository, and unknown files cannot be submitted.
Remember to select Add to add it to the repository.
After the addition is complete, it becomes a blue plus sign, indicating the newly added version library file.
Next, just write the code and submit it.
Deleted files should also be right-clicked and submitted, as follows.
Remember to check the status of your files at any time, and if they are not added to version control, add them in time, otherwise your files will not be submitted.
renew
Suppose you and classmate B are collaborating. After classmate B wrote the code and submitted it to SVN, if you want to get the latest modification, you need to select update (if there are new ones submitted by others on the server, you cannot submit them, you must update them before submitting).
How do I know if the server has been updated? You can directly choose to update, and you will know if there is an update. Or right-click to check for changes, and then check the repository to see which files have been changed on the server.
Right-click and select HEAD and BASE to compare.
The one on the left represents your code, and the one on the right represents the code on the server.
If there are changes, remember to update to the local in time and then continue to work.
But sometimes the update will conflict, for example, you and the server have changed the same place.
At this point you need to update to resolve the conflict.
It will prompt you which file is in conflict, you just need to open that file and resolve the conflict as required.
<<<<<<.mine to ==== for your code, others for the server's code. You just change to what you want.
Then select Resolve and tell SVN that I have resolved the conflict.
The rest is the update submission operation between team collaborations, which will not be repeated here.
View logs
Choose to show the log, you can see what the people in the team have done.
You can see who is who, what time, and what. The last column of information was written when I submitted it myself. It is recommended that you fill in the submission information when submitting, so that others can see what you have done. Submitting information is also good for you, and you can see what you did after a long time.
version rollback
If you change something, but haven't committed it yet, you can use the revert feature.
But what if we wrote something wrong and committed it? Version rollback allows you to restore files to
previous versions. Right-click to update to the version, select the version by viewing the log, and then roll back.
Sometimes we need to look at previous versions of the code. At this point we can create a new folder to check out to the specified version.
version control
There are several methods of version control, as follows.
This is the easiest way to add version information when submitting a release build.
Tagging
Every release should be tagged. Right click and select branch/tag. Label the to path with the version number
so you have a v1.0 version label.
If you want to view a certain version of the code in the future, just switch to the past
Summarize
In our daily use, the most commonly used are update and commit operations. These two steps must be very skilled. The other thing you can do when you run into problems is to look at the documentation. In addition, it should be noted that all version control tools can only track text files (files that can be opened and viewed with Notepad), and don't expect SVN to record which line you changed in word. Once you encounter a word conflict, remember to carefully compare the two versions, and then resolve the conflict.