svn branch development and trunk merge (branch & merge)

 

 

[Reprinted address: http://blog.csdn.net/zhouyong0/article/details/7968667, the original address is unclear]

Below I will demonstrate step by step how to complete branching and merging, including creating branches, branch development, branch and main line synchronization, the whole process of branch merging into the main line, and even how to create a test repository locally.

First you need to install TortoiseSVN, the version I installed is: TortoiseSVN 1.6.15, Build 21041 - 32 Bit , 2011/03/23 18:00:27

1. Creation of local Repository

The creation of the repository is very simple. Suppose I want to create a repository in the D:\TortoiseSVN\TestRepository directory. Just right-click the TestRepository directory and select "TortoiseSVN" -> "Create repository here" to complete the creation of the repository.

2、Check out

Suppose you want to check out to D:\TortoiseSVN\TestSVN, it is also very simple, create the TestSVN directory under the D:\TortoiseSVN directory, then right-click on the directory, select "SVN Check out...", in the pop-up window, Fill in "file:///D:/TortoiseSVN/TestRepository" in "URL of repository", other defaults can be used, and finally click ok.

3. Trunk creates a new project MyProject

It's quite simple and I won't go into details, just list the modifications made in this operation:

4. Create branch

Right-click on the /trunk/MyProject directory, select "TortoiseSVN" -> "Branch/tag..." in turn, fill in the address of the branch in "To URL" in the pop-up window, and select HEAD revision for the target revision, as shown below As shown, after adding the log, click the ok branch to create it. This operation is very fast. The newly created branch in the repository is actually just a soft link pointing to a revision of the trunk, and no files are actually copied.

5. Check out branch

Right-click the TestSVN directory and select "TortoiseSVN Update" to download the newly created branch back to the local. Enter the /branches/MyProject directory and you will find that its file structure is exactly the same as /trunk/MyProject.

6. branch submits a new file

7. The trunk then submits a modification

8. branch submits a modification again

9. Synchronize changes in trunk to branch

6-8 demonstrates that branch and trunk are being developed independently and in parallel. To prevent going further down the "wrong" path, the branch now realizes that it is time to do a sync with the trunk (merge the trunk into the branch).

First, update the local trunk first, resolve conflicts if there are conflicts, and ensure that the trunk and repository have been completely synchronized, then right-click on /branches/MyProject, select "TortoiseSVN" -> "Merge..." in turn, in the pop-up Select the first item "Merge a range of revision" in the window. This type of Merge has been introduced very clearly and is suitable for merging changes between multiple revisions submitted on a branch or mainline to another branch.

After clicking next, the following window appears:

Since it is to be merged from trunk to branch, of course, "URL to merge from" here should fill in the path of trunk. "Revision range to merge" is well understood, that is, which revisions of trunk you want to merge into branch. , which can be a series of revisions, such as 4-7, 15-HEAD, or a single revision number. Since in r4, trunk modifies the talk() method in Person.java, the revision here only needs to fill in 4. After clicking next, the following image appears:

Just keep the default settings here. Before clicking the Merge button, you can Test the merge to see if it is successful or not, and the details of the merge. After clicking the Merge button, the changes made by the trunk will be synchronized to the branch.

10. Submit the merged branch

So far, branch has been completely synchronized with trunk, and the codes of branch and trunk are getting along very well without any conflict. If branch has been developed, it is time to merge branch back into trunk. Of course, if branch continues to develop, then you will Repeat steps 6-10 over and over again.

11. Merge branch back into trunk

Right-click on /trunk/MyProject (note the right-click on the main line directory), select "TortoiseSVN" -> "Merge..." in turn, in the pop-up window, select the second item "Reintegrate a branch" for Merge type, This type of merge is suitable for merging all changes back into the mainline after the branch has been developed.

After clicking next, the following window appears:

在这里,"From URL"选择/branches/MyProject,无需选择revision号,Reintegrate会将branch上所有修改合并到trunk。后面的步骤和上文第9步中的一样,不再啰嗦了。如无意外,branch将成功合并到trunk,你需要做的只是将合并后的trunk赶紧commit!

12、提交合并后的trunk

合并后的项目上右键,Temp -> Commit。

13、删除branch

如果你认为你新加的功能已经开发完成了,你可以删除你的分支!

 

14、查看log信息

到这里,我已经给你演示完了整个过程,不过最后我们还是看看所有的log信息吧,通过log能发现我们干的所有事情:

r1-r7正是我上文在干的事情,从Message中你能发现我对trunk和branch都干了什么,另外,在Log Messages窗口的左下角勾选了"Include merged revisions"你还能看到额外的Merge information:

图中灰色的是和merge相关的log,共发生了两次merge,第一次是在r6,在r6中,branch合并了trunk在r4时提交的变化;第二次是在r7,在r7中,trunk合并了branch从r2到r6的所有变化。

Guess you like

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