This post was reproduced in: http://www.cnblogs.com/armyfai/p/3985660.html
I was purely for the record.
About SVN:
Why use SVN?
Programmers in the process of writing a program, each programmer will generate a lot of different versions, which requires the programmer to effectively manage the code, when needed, can be quickly and accurately remove the corresponding version.
What is Subversion?
It is a free/open source version control system, a set of files stored in the central repository, record every file and directory changes, Subversion allows to restore the data to an earlier version, or check the history of data modification, subversion can access its repository through the network, This allows the user to operate on different computers.
One: SVN server build and use.
1. First to download and build the SVN server , as follows : http://subversion.apache.org/packages.html, after entering the URL, scroll to the bottom of the browser to see the following:
Personally, it is best to use VISUALSVN server servers and TORTOISESVN clients . Click the visualsvn connection above to download visualsvn server, When the download is complete, double-click Install, such as:
Click Next Next, as follows:
Then click Next, Next, as follows:
Click "Next" below:
location refers to the installation directory of VISUALSVN server , Repositorys is the directory where you specify your repository . Server port Specifies a port , and use secure connection Shan means that a secured connection is used.
Click next to proceed to the next step, such as :
Then click "Install"to enter the following installation diagram:
After the installation is complete, click "Next" to proceed to the next step: for example
Click "Finish" to complete the installation. When the installation is complete, start visualsvn Server Manager:
You can see some information about the repository on the right side of the window , such as status , logs , user authentication , repository, etc.
To build the repository , you need to right-click the repositores in the left window , such as :
In the popup context menu, choose Create New Repository or create new ->repository:
Go to the next step, such as:
Click "Next", such as:
Click "create", such as:
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, select Create User or create a new->user:
Click on user to enter such as:
after filling in username and password, click the OK button to enter the following:
Click on the "Add" button above, as
Add longen0707 to the user (if there are multiple users, the same action ).
2. Then we set up the user group , right-click the user group on the left side of the VisualSVN Server Manager window , select Create group or create a new ->group:
Click on the "Group" button to enter such as:
In the pop-up window, fill in the group name as developers, then click the Add button , select Developer in the pop-up window, add to the set , then click Ok.
Next we need to set permissions for the user group, right-click on Myrepository, select properties:
In the dialog box that pops up, Select the Security tab , click the Add button , select longen0707, and then add it, with the permissions set to Read/write, as :
Click on the "OK" button.
Two: Client SVN installation.
1. First we need to download "svn Little Turtle" after the installation. For example I downloaded the following:
After the installation is complete, for example, in my project in qiandaun1, I can right-click to see the following:
Description SNV has been installed successfully!
2:checkout the project file.
New or entered directory (e.g. Qianduan1), right---Svn Checkout--
Where the URL I can get from the SVN server, I right-click on the new file under Myrepositories
The Qianduan file is built, and then like me right--- copy under
Can.
Paste the copied repository URL, such as:
Click "OK" button, you can retrieve it, as follows:
Such as:
Precautions:
. SVN this hidden directory records two key messages: The baseline version of the working file and the timestamp of the last update of a local copy, and never manually modify or delete this. SVN hides the directory and the files inside!!, otherwise it will cause your local working copy (static attempt) to be destroyed, No further action is possible.
1) tortoisesvn icon Introduction
A newly checked work copy uses a green checkmark overload to indicate that the subversion status is normal.
After you start editing a file, the state becomes modified, and the icon reload becomes a red exclamation point. In this way, you can easily see that those files have been modified since you last updated the working copy and need to be submitted.
If a conflict occurs during the commit process, the icon becomes a yellow exclamation mark.
The plus sign tells you that a file or directory has been scheduled to be added to version control.
2) TortoiseSVN client base operation:
1. svn Checkout (svn Checkout)
Right-click in the folder or directory -> select svn Checkout, as shown in
After clicking, enter the repository's directory address in the pop-up window's repository URL box and click OK, as
Then click on the OK button, such as:
Enter the user name and password in the dialog box that appears, and after verification succeeds, the project file starts to download from the remote server to the local working directory.
When you click the OK button, you can get it done, as shown in:
2. Add (add)
Under the test project file, create a new B.txt file, and submit it to the repository in the following 2 ways:
1. First mention the change list, then commit to the configuration library, select the new file, right-click on the SVN menu to execute the "ADD" action submitted to the "Change list", and then right-click on the SVN menu "svn commit" commit to the repository.
2. Do not submit to the list of changes, but directly in the Commit configuration library, select the file, right-click on the SVN menu to perform an "SVN Commit" operation.
3. Deletion (delete)
If the deleted file is not yet in the repository, you can delete the file directly using the operating system's delete operation.
If the deleted file is already in the repository, the method of deletion is as follows:
- Select the deleted file, right-click on the SVN menu to perform a "delete" action, then select the deleted file's parent directory, right-click on the SVN menu to execute "SVN Commit".
Delete the file using the delete operation of the operating system, then select the parent directory of the deleted file, and right-click the SVN menu to execute "SVN Commit" and select the deleted file in the change list. Such as:
4. Renaming (Rename)
Modify the filename, select the file or folder you want to rename, then right-click "Tortoisesvnàrename", enter the new name in the dialog box that pops up, click "OK" button, and submit the file or folder after the modified file name to the SVN server via "SVN commit".
5. svn Restore (svn Revert)
Right-click the file or folder you want to fallback, and select "Update to reversion ..." in the TortoiseSVN pop-up menu. A window will then pop up, as follows:
For example, to return to the first 10 versions, just fill in the appropriate version number in revision and click OK.
6. Checking for updates (check for modifications)
This feature can show that you have made the changes have not been submitted, this feature can not only see changes to the file change, all the changes can be seen, including adding files or directories, delete files or directories, moving files or directories, etc., if you click on the check repository, you can also see the version of the repository changes, You have not updated it to local, as follows:
7. svn updates (svn update)
Update the local code consistent with the latest version of the SVN server, simply right-click on the folder you need to update or right-click on the blank in the file, select "SVN Update" (Get the content in the specified version, right-click on "Update to reversion" in the SVN menu) , you can do it.
7.1 How to resolve conflicting files
For each conflicting file subversion placed three files in your directory: the following:
Why would a conflict code be generated? The reason is very simple is because different people, at the same time modified the same file of the same place, when he submitted, I did not submit, I will not submit, this time we have to update, and then commit, if there is a conflict, it will generate the above 3 files.
The solution is as follows :
First we can look at the 1.txt code as follows:
<<<<<<<. Mine
aaaasdf11222333 Dderderder
=======
B>>>>>>>. R5
And then I get rid of the extra code, and 1.txt becomes this
aaaasdf11222333 Dderderder
Commits, or cannot be submitted, as follows:
Why? Because the conflict will produce the above three files, there are 3 files above the existence of affirmation cannot be submitted, these three file codes and explanations are as follows:
- 1.txt.mine is a pre-conflict own file. You can look at the following content:
aaaasdf11222333 Dderderder
2.1.TXT.R4 is a pre-conflict local version file
The contents are as follows: aaaasdf11222333
3.1.TXT.R5 is the version that someone else has to commit before you
The contents are as follows: b
Among them, <<<<<<<<.mine ... the code between ======= is your own, and ======......>>>>>>>. R5 is the part of someone else's code that conflicts with you.
It is not difficult to understand why the conflict is such a strange thing, because you modify the same piece of code, of course, will create conflicts.
The solution is as follows:
- If I am in the 1.txt now the conflict content is as follows:
<<<<<<<. Mine
6666666666666600000
=======
66666666666aaaaaaaaaa666
>>>>>>>. R16
Previously said <<<<<<< mine ... =======
...... The code between is the code that I modified before I produced the conflict,
======= .........>>>>>>>. R16 This middle ... The code is someone else with me conflict code part, from the above code can see Aaaaaaaaa is my colleague new, 00000 is I added later.
- uses the revert (rollback) operation, which means that the user abandons his or her update code and submits it directly, and this time your code will make the latest code on the server, the new code submitted by a user, and your code will not be committed as follows:
click ok button can see the other three files are automatically deleted, 1.txt code into the following code:
66666666666aaaaaaaaaa666
a user-submitted code, my own updated code needs to be copied in-person to submit commit.
- If I now have a 3.txt conflict code as follows:
< <<<<<< .mine
333333338888888888888===== = =
3333cccccccccc3333>>>>>>>. R16
through the 1th we know, 333333338888888888888 this content is I modified, did not create a conflict before the content, 3333cccccccccc3333 this code is a user-submitted code , I learned from the above that a user new content is CCCCCCC, and my new content is 8888888.
so the second solution is as follows:
Select File, right-click Editconficts: This method requires the conflicting parties to negotiate after the code changes are unified before committing. Not only resolves the conflict but also ensures that the code is correct, because only one of the code is committed.
As shown, the red part is the conflict code: theirs represents the current server-side of the latest code, mine represents its own modified code, merged represents the merged code. Right-click on the Red button to select: Use this text block can be used as the combined code
Let's talk about the situation where the important code is overwritten because of the conflict. When a conflict occurs, if the action is not correct, it can cause some code to be lost, and it is easy to restore the previous code.
Select File-Right-select Show log in this area you can see all the versions that were submitted before, find the version you want to restore right-click on the revert to this release to restore.
SVN commit (SVN commit)
SVN commits the changes made in the workspace, including changes to the contents of the file, additions to the file or directory, deletion, naming, moving, and so on. As shown in the following:
8. Show logs ( show log)
Who can be found by this feature, and when, for those files in that directory, such as:
9. Repository Browsing (repo-browser)
This function is used to browse the database to be viewed, right click on the local folder, select TortoiseSVNàrepo-browser, enter the repository address in the popup dialog, and then enter the username and password. You'll be able to see what you need to see in the repository, and where you can see who locked up the files, such as:
Three: Create branch merge interoperate
Why do I create a branch and merge in a project?
For example, I now project all the files on the trunk (trunk), due to changes in demand, need to add new requirements, but we have to continue to develop on the backbone, where we can create a new branch to do to increase the demand of the piece, the trunk continues to develop, and so on branch code no problem, and merge them into the trunk.
The main purpose of creating a branch is to develop parallel with the mainline without affecting the development of the mainline.
How does it work?
If I create a new folder locally, test has 2 folders trunk (store the code on the trunk) and branch (the Code on the branch), as follows:
First: Extract the code on the trunk.
Click on the trunk--right--click SVN Checkout--Pop up a dialog box as shown:
The above URL is obtained from the server on VISUALSVN server, as follows:
Right-click Qianduan3---Copy URL to Clipboard.
Where the QIANDUAN3 project has the following files, as shown in:
When you finally click on the Checkout button above, you can get the code from the remote server on the trunk as follows:
Second: New branch
The steps to create a branch (branch) from the trunk (trunk) are as follows:
1. Right-click Trunk---Branch/tag:
In the popup dialog box such as:
After clicking the OK button, you can add Newbranch on the VisualSVN Serval server, which is a copy of the file from the server qianduan3 above, as shown below:
Now we can take a look at the local branch folder, I now directly into the branch file, right-and chenckout under, you can newbranch all the files extracted, as follows:
Click the OK button to extract the file, as shown in:
The branch is currently built on the server side of SVN and is not updated locally, and the local branch folder can be updated to the branch code by right----and update, as follows:
Four: Merging branches to the trunk
For example, I now add a 3.txt file to the branch branch and then submit it as follows:
Now I want to merge the code 3.txt from the branch onto the trunk trunk, how do I merge it now? The steps are as follows:
1. Back to our just trunk folder, right-click the folder----TortoiseSVN--and Merge as shown:
In the popup window, as shown in:
Then click on "Next" next, as shown:
Then "Next" next, as shown:
You can see that the trunk trunk is added with a 3.txt, which is merged from the branch.
Five: Merge trunk to branch.
If there are some updates on the trunk, such as jar updates and so on, how do they update to the branch? For example, I now create a new 4.txt file on the trunk, such as the following:
My current branch directory is as follows:
Now you want to merge the 4.txt on the trunk to the branch, how do I do it?
The steps are as follows, or similar to just the operation.
1. We click Branch on the branch--right-tortoisesvn as shown in the Merge:
After the new window pops up, as shown:
Then click on "Next" next, as shown:
Continue to the next step, such as:
At the end of the merge, you can see that the branch branch also has 4.txt files on the trunk, which means that merging the trunk to the branch is also possible, as shown in:
SVN Usage Tutorial Summary