SVN and TortoiseSVN Combat: TortoiseSVN New and merged branches

Source: Internet
Author: User
Tags tortoisesvn

Hard canton: "SVN and TortoiseSVN Combat" series has written two, the first "SVN and TortoiseSVN Combat: from Beginner to proficient", about the branch and label knowledge Introduction can be read the second "SVN and TortoiseSVN Combat: Tags and branches", This article focuses on the actual operation of TortoiseSVN new and merged branches through examples.

First of all, online most of the explanation of the branch merger is wrong, for other materials please be cautious, this article in the spirit of scientific rigorous, to ensure that the correct explanation.

I have created a new good one SVN project repository and created a new trunks, tags, branches three directories according to the directory structure of the standard project warehouse described in the second article:

The actual operation begins below.

New branch with TORTOISESVN

Because these three directories are just built, in order to better reflect the branch of the new and merge the impact of the code in the project, first forge Point code files.

Open the Trunks directory and create a new two text file A.java,b.java in the trunks directory:

Open A.java to enter the following:

The B.java file can be entered randomly, in this case the main use is to observe whether the subsequent changes.

Two files when you are done editing, use SVN commit to commit the changes to SVN:

The following begins the creation of the branch:

1, right click on the trunks, select Branch/tag in the TortoiseSVN menu;

2, enter the path to the new branch in the To path input box, usually:/branches/branch name, which is equivalent to the branch saved path name;

3, select the head revision in the repository, for the current SVN trunks directory under the latest Code branch, if you need to set up a branch of revision, you can choose;

4. Click OK to set up the branch to complete.

Open the branches directory, the discovery directory is still empty, there is no branch just established, this is because the operation of the branch is done on the server side, when the need to edit the branch, in the branches directory click Update, the branch just created will be downloaded.

The process of establishing a branch is very fast and will not slow down because of the number of files in the trunk, for reasons of subsequent explanation.

Merging branches with TORTOISESVN

The second article cited, there may be trunk, branching parallel development situation, below we simulate.

Update the branch you just created, open the A.java in the branch, and edit it as follows:

To open the A.java in the Trunks trunk, edit it as follows:

Changes to the above two files basically simulate the branch, trunk parallel situation, two directories under the same file is modified separately.

Commit the changes to the above two files and merge them below.

The following begins merging branches into the trunk:

1, right click on the trunks, select Merge in the TortoiseSVN menu;

2. Select the second item in the popup window, which can be understood as merging two trees;

3. Select the branch directory to merge in from and to;

4, in from the revision choose to create the branch when the revision, specifically click on the show log, select the bottom of the bar;

5, in to the Revision select Head Revision, that is, the latest operation;

6, click Next, the next page use the default, click on the merge;

7, the merger is completed.

This time you will find that the files in the trunks directory have been modified, when the merge operation is done locally, and is not submitted to SVN, which differs from the branch establishment, please note.

This means that if you find a problem in this merger, you just need to revert the trunks directory and discard the merge.

Can look at the Trunks directory merged with the A.java file, everyone with the previous control, we have achieved the desired merger effect:

What happens when you create a branch

The SVN server's copy of the branch is very efficient, instantaneous, and requires little space to store, so there's no need to worry about branching out too much causing the project's warehouse bloat.

It can be understood that SVN stores a reference to a file in the server, not a physical copy.

Do not merge the same branch to the trunk multiple times

One principle of merging branches is not to merge a branch into the trunk multiple times, although you might have made changes to the branch after merging, and there is a reason for that.

The above mentioned in the Merge branch, in the revision option from the need to select the real version of the merge, if the first merge only need to select the earliest version can be, but if the merge once, you can really remember the last time you merged the final revision?

A good operation is to create a new branch after merging.

Merge trunk to Branch

In fact, merging is a reversible process, merging the trunk to the branch and merging the branches to the trunk is exactly the opposite of the operation, and if you have another one it should be very simple.

I do not show here, if you really need to be able to comment on the blog, we really need to write it.

Record, for the better of myself!

SVN and TortoiseSVN Combat: TortoiseSVN New and merged branches

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.