SVN Branch
The Branch option creates another line for developers. This option is very useful when someone wants to split the development process into two different lines.
For example, the project demo has two teams, and under svn there is a trunk version.
Due to sudden changes in customer requirements, the project needs major modifications. At this point, the project team decides that Team 1 will continue the original half-finished work (a certain module), while Team 2 will develop the new requirements.
At this point, we can create a branch for Team 2. A branch is actually a copy version of the trunk version (mainline), but the branch also has version control functionality and is independent of the mainline. Of course, in the end, we can use the (merge) function to merge the branch back into trunk, thus finally merging it into one project.
In the local copy, we create amy_branchbranch.
root@example:~/svn/example01# ls branches tags trunk root@example:~/svn/example01# svn copy trunk/ branches/my_branch A branches/my_branch root@example:~/svn/example01#
View status:
root@example:~/svn/example01# svn status A + branches/my_branch A + branches/my_branch/HelloWorld.html A + branches/my_branch/readme
Commit the newly added branch to the repository.
root@example:~/svn/example01# svn commit -m "add my_branch" Adding branches/my_branch Replacing branches/my_branch/HelloWorld.html Adding branches/my_branch/readme Committed revision 9.
Next, we develop on the my_branch branch, switch to the branch path, and create the index.html file.
root@example:~/svn/example01# cd branches/my_branch/ root@example:~/svn/example01/branches/my_branch# ls HelloWorld.html index.html readme
Add index.html to version control and commit it to the repository.
root@example:~/svn/example01/branches/my_branch# svn status ? index.html root@example:~/svn/example01/branches/my_branch# svn add index.html A index.html root@example:~/svn/example01/branches/my_branch# svn commit -m "add index.html" Adding index.html Transmitting file data . Committed revision 10.Switch to trunk, run svn update, and then merge the my_branch branch into trunk.
root@example:~/svn/example01/trunk# svn merge ../branches/my_branch/ --- Merging r10 into '.': A index.html --- Recording mergeinfo for merge of r10 into '.': G .
At this point, view the directory, and you can see that the index.html file created in the my_branch branch has been added to trunk.
root@example:~/svn/example01/trunk# ll total 16 drwxr-xr-x 2 root root 4096 Nov 7 03:52 ./ drwxr-xr-x 6 root root 4096 Jul 21 19:19 ../ -rw-r--r-- 1 root root 36 Nov 7 02:23 HelloWorld.html -rw-r--r-- 1 root root 0 Nov 7 03:52 index.html -rw-r--r-- 1 root root 22 Nov 7 03:06 readme
Commit the merged trunk to the repository.
root@example:~/svn/example01/trunk# svn commit -m "add index.html" Adding index.html Transmitting file data . Committed revision 11.Other Extensions