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, under the project demo there are two groups, and under svn there is a trunk version.
Due to a sudden change in customer requirements, the project needs significant changes. At this point, the project team decides that group 1 will continue the half-finished work (a certain module), while group 2 develops the new requirements.
At this point, we can create a branch for group 2. A branch is essentially a copy of the trunk version (main line), but the branch also has version control and is independent of the main line. Of course, in the end, we can use the (merge) function to merge the branch into the trunk, eventually combining them into one project.
We create one in the local copy my_branch branch is not executed.
root@runoob:~/svn/runoob01# ls
branches tags trunk
root@runoob:~/svn/runoob01# svn copy trunk/ branches/my_branch
A branches/my_branch
root@runoob:~/svn/runoob01#
View status:
root@runoob:~/svn/runoob01# 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@runoob:~/svn/runoob01# svn commit -m "add my_branch"
Adding branches/my_branch
Replacing branches/my_branch/HelloWorld.html
Adding branches/my_branch/readme
Committed revision 9.
Then we go to the my_branch branch for development, switch to the branch path, and create the index.html file.
root@runoob:~/svn/runoob01# cd branches/my_branch/
root@runoob:~/svn/runoob01/branches/my_branch# ls
HelloWorld.html index.html readme
Add index.html to version control and commit it to the repository.
root@runoob:~/svn/runoob01/branches/my_branch# svn status
? index.html
root@runoob:~/svn/runoob01/branches/my_branch# svn add index.html
A index.html
root@runoob:~/svn/runoob01/branches/my_branch# svn commit -m "add index.html"
Adding index.html
Transmitting file data .
Committed revision 10.
Switch to trunk, run svn update, then merge the my_branch branch into trunk.
root@runoob:~/svn/runoob01/trunk# svn merge ../branches/my_branch/
--- Merging r10 into '.':
A index.html
--- Recording mergeinfo for merge of r10 into '.':
G .
Now check the directory and you can see that the index.html file created by the my_branch branch has been added to trunk.
root@runoob:~/svn/runoob01/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@runoob:~/svn/runoob01/trunk# svn commit -m "add index.html"
Adding index.html
Transmitting file data .
Committed revision 11.