Svn Branch
Title: SVN Branch |
* * *
The Branch option gives developers another line of development. This option is very useful when someone wants the development process to diverge into two different lines.
For example, there are two teams under the project demo, and there is a trunk version under svn.
Due to sudden changes in customer requirements, the project needs to make significant changes. At this point, the project team decides that Team 1 will continue to complete the work that was halfway done (a certain module), and Team 2 will develop the new requirements.
In this case, we can create a branch for Team 2. The branch is actually a copy of the trunk version (the main line). However, the branch also has version control functionality and is independent from the main line. Of course, in the end, we can use the (merge) function to merge the branch into the trunk, thus finally merging them into one project.
We create a **my_branch** branch in our local working copy.
root@tutorial:~/svn/tutorial01# ls branches tags trunk root@tutorial:~/svn/tutorial01# svn copy trunk/ branches/my_branch A branches/my_branch root@tutorial:~/svn/tutorial01#
Check the status:
root@tutorial:~/svn/tutorial01# svn status A + branches/my_branch A + branches/my_branch/HelloWorld.html A + branches/my_branch/readme
Commit the new branch to the repository.
root@tutorial:~/svn/tutorial01# 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 go to the my_branch branch for development, switch to the branch path and create an index.html file.
root@tutorial:~/svn/tutorial01# cd branches/my_branch/ root@tutorial:~/svn/tutorial01/branches/my_branch# lsHelloWorld.html index.html readme
Add index.html to version control and commit to the repository.
root@tutorial:~/svn/tutorial01/branches/my_branch# svn status? index.html root@tutorial:~/svn/tutorial01/branches/my_branch# svn add index.html A index.html root@tutorial:~/svn/tutorial01/branches/my_branch# svn commit -m "add index.html"Adding index.html Transmitting file data .Committed revision 10.
Switch to trunk, execute svn update, then merge the my_branch branch into trunk.
root@tutorial:~/svn/tutorial01/trunk# svn merge ../branches/my_branch/--- Merging r10 into '.': A index.html --- Recording mergeinfo for merge of r10 into '.': G .
Now check the directory, you can see that trunk already has the index.html file created by the my_branch branch.
root@tutorial:~/svn/tutorial01/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@tutorial:~/svn/tutorial01/trunk# svn commit -m "add index.html"Adding index.html Transmitting file data .Committed revision 11.
YouTip