SVN is that simple

What is SVN

SVN full name: Subversion, is an open source version control system

Svn is a centralized file version management system . The core of centralized code management is the server . Before starting a new day's work, all developers must obtain code from the server, then develop, and finally resolve conflicts and submit.

Centralized file version controller: All files are handed over to the server for unified management. Since there is a server, it needs to be connected to the Internet to operate.

Why use SVN

When we write a project, it is usually written by a team. If we do not use SVN, then we can only copy each other's code in the team to complete our project .

SVN also has the following benefits:

  • Easily compare the subtle differences between different versions [modify the code, there is a version number, and you can know the data before and after the modification]
  • Keep abreast of the progress of other members of the team [if the code is not submitted to the server, it is slow to do]
  • Wide area network sharing [you can code sharing when you connect to a local area network]
  • Work collaboratively to greatly improve team work efficiency

Quick introduction to SVN

Configuration library

There is a concept of configuration library in SVN, so what is it? ?

It stores all the data, and the configuration library stores the data in the form of a file tree

  • Include directories and files

Any number of clients can connect to the configuration library, read and write these files . And can add read and write logs , and authorized users can easily see these changes

working copy

We already know from above that we can get the desired file from the configuration repository. Then we have to download the file from the configuration repository. This downloaded area is the working copy .

This working copy is actually the area where we work . After we modify those files, we can submit them to the configuration repository again .

SVN commands

Let's simply learn a few SVN commands. SVN has the function of a graphical interface, so command learning is not necessary. Learn about....


	---创建服务器端版本库
	svnadmin create 版本库路径 
	
	---启动SVN服务器端
	svnserve -d -r 版本库路径 
	
	---在系统服务中注册svn服务器
	sc create svn binPath= "C:\Program Files\TortoiseSVN\bin\svnserve.exe --service -r D:\itcast\svnserver\20150118svn" DisplayName= "svn服务"
	
	---删除系统服务中的 服务
	sc delete 服务ID

If you start the SVN server, it will start normally without reporting an error .

 

write picture description here

 

assign permissions

Find the svnserve.conf configuration file under the conf folder in our configuration library. Uncomment the following three lines

 

write picture description here

 

Assign users

Find passwd under the conf file and configure the user

 

write picture description here

 

common subcommands

  • import: Commit files or directories that are not included in the version controller into the repository (execute only once)
  • checkout: checkout the working copy from the repository tag
  • revert: restore the working copy file to the specified version
  • update: merge changes from the repository into the working copy
  • commit: Commit the changes to the working copy to the repository.

Use SVN

Add data to SVN

To create a configuration library, we can use the command line method or the UI click method. Here I use the UI method directly.

 

write picture description here

 

Then, start our SVN service

 

write picture description here

 

Put a folder into the configuration repository and let it be managed by SVN

write picture description here

 

 

write picture description here

 

See what we added in SVN:

 

write picture description here

 

View specific logs

write picture description here

 

It is very clearly marked:

 

write picture description here

 

Export data from SVN

Export SVN data to users.

 

write picture description here

 

After export: this local folder is actually our working copy!

 

write picture description here

 

Modify the data exported by SVN and add it back to SVN

I added a file to the working copy

write picture description here

 

Add to SVN:

write picture description here

 

Subsequently, it becomes a blue icon + sign, and we submit.

 

write picture description here

 

 

write picture description here

 

conflict resolution

We may have a problem like this: our SVN is being developed by a team. But before the commit, someone modified the file I was editing. So when I submitted it, there was a conflict [the current data is inconsistent and conflicted]

The localhost2 user exported the SVN data and modified the file:

 

write picture description here

 

Another user localhost is also modifying the file, but it is not doing updata operations. Not knowing that the file has been modified.

 

write picture description here

 

When he finished the modification and wanted to update to SVN, he found a conflict.

 

write picture description here

 

In the face of conflict, we have two options:

  • Abandon this modification
  • Check what the content of the conflict is, and then decide which data you want when you are finished, or merge it.

 

write picture description here

 

We go to the conflicting page and decide which row of data we want

 

write picture description here

 

 

write picture description here

 

After making the final changes, click Save.

 

write picture description here

 

Advice on conflict

  • Before modifying the file, perform an update operation first
  • After the modification is completed, commit in time, do not stay locally for a long time
  • When collaborating with multiple team members, try to revise the parts written by yourself, and try not to revise the parts that are not written by yourself
  • Conflicts are normal and can be resolved by the previous method, do not overwrite each other

work flow chart

 

write picture description here

 

If there are any mistakes in the article, please correct me, and we can communicate with each other. Students who are accustomed to reading technical articles on WeChat and want to get more Java resources can follow WeChat public account: Java3y

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325391596&siteId=291194637
svn