SVN merge and branch

Source: Internet
Author: User

 

When extracting code from the svn repository, you must not extract the entire repository. Instead, you should retrieve only the trunk main directory or only a branch directory under branch.

A project will be jointly developed by multiple people. The basic process is:

1. Each Development Team (city or district) should establish its own branch and develop it on it;

2. Developers merge branches to the trunk to form a stable version;

3. Each member creates a new branch from the trunk and develops the branch (that is, return to the first step)

4. the cycle repeats until the project ends.

Branch and merge

The basic concept of a branch is just like its name. A line developed is independent of another line. If you review the history, you can find that the two lines share the common history, A branch always starts from a backup and develops its own unique history (as shown in)

 

(1) create a branch
Suppose the layout of projects in our current version library is as follows:

 

Our project is placed in the trunk (Main Line) directory, as well as the branch (Branch) and tags (TAG) directories, this layout aims to better differentiate the positions of the main line, branch, and tag.

The Subversion pair and tag are achieved by copying a snapshot of the latest version library.

Start to create branch: Right-click the main line Directory (trunk) of checkout, and select "branch/Tag ..."

In the pop-up window, point to URL to the branch directory and enter the specific directory name of the branch. Here is mybranch1.0. The branch we will create will be stored here. Click OK.

Update the local branch directory and you will see the branch "mybranch1.0" you just created. This completes the creation of our branch.

The biggest purpose of creating a branch is to perform parallel development with the main line without affecting the development of the main line.
Because all the commits you make on the branch are only saved on the branch, the update on the main line cannot see the modification of the branch. As shown in, trunk can only see version r344 and version r343.

(When should I use a branch? For example, if you have received a task that requires the cooperation of three or four people and you need to share resources, you can create a branch for this task, the personnel involved in this task will perform development on the branch, and then merge them to the main line after completion, so that half of the incomplete functions will not be submitted to the main line, affects the normal operation of the main line. Or you need a long development cycle to complete the task. If you haven't submitted the resource for such a long period of time, you can discard it if you lose it. Of course, the Branch is not only used in such cases, but also can be used in many other cases .)
Note that due to long-term independent development, many conflicts may occur when the branches are merged back to the main line. Therefore, if an update of the trunk is found during the development period on the trunk line, and this update may conflict with you in the future, you can merge the content of the trunk line into the branch first. You do not need to wait until a large number of modifications are made before updating. (In fact, this process is the same as merging branches to the main line, but the destination is different .)
For example, if we use version 3 on the main line, how can we merge the version information into the branch?

Merge ...". À right-click the branch root directory and choose tortoisesvn

Here, we must first understand the key concept behind a merger.
Everything that happens during the merge process: first compare the two version library trees and then apply the differences to the local copy.
This command includes three parameters:
1. The initial version tree 2. The final version tree 3 is a copy of the work that receives the difference.
After understanding these concepts, let's proceed.
In the displayed window, select the main line directory and its version number (the initial version tree), and then select the main line Directory and the latest version number (the final version tree ), it can also be a version number, but it should be higher than the version number of the initial version tree. By default, the receiving area is the directory you right-click, and mybranch1.0 is used here.
Before merging, you can click "unified diff" to view the changes in the content of all files in the two version trees. "Diff" displays the list of files that have changed, "Dry run" displays the status information of a merge, but does not perform any merge operations. Click "merge ".

Click "merge". The merged file (that is, the file on the branch is replaced with the content modified on the main line ), if no conflict exists, you can use it on the branch as other files. If the merged content is not satisfactory, you can cancel the merge operation by undoing it, the premise is that the merged files are not submitted.

Branches are merged to the master line and the master line to merge content to the branch.
The difference is that
1. The first version library is the version created by the branch.
2. The end version library is the version after development.
3. The purpose of the application is the main line directory.
About the copy and label of the conversion job (the label works in the same principle as the branch in subversion. A branch that does not make any modification is a snapshot of the version library at a certain time, it is equivalent to creating a tag for a specific version)

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.