Easy Tutorial
❮ Svn Install Home ❯

SVN Branch


The Branch option allows developers to create an additional line of development. This is particularly useful when someone wants to split the development process into two distinct lines.

For example, under the project demo, there are two groups, and there is a trunk version under SVN.

Due to a sudden change in customer requirements, significant modifications are needed for the project. The project team decides that Group 1 will continue with the work they were halfway through (a certain module), while Group 2 will develop the new requirements.

At this point, we can create a branch for Group 2. A branch is essentially a copy of the trunk version (mainline), but it also has version control capabilities and is independent of the mainline. Eventually, we can merge the branch back into the trunk, resulting in a unified project.

We create a branch named my_branch in our local copy.

root@tutorialpro:~/svn/tutorialpro01# ls
branches  tags  trunk
root@tutorialpro:~/svn/tutorialpro01# svn copy trunk/ branches/my_branch
A         branches/my_branch
root@tutorialpro:~/svn/tutorialpro01#

Check the status:

root@tutorialpro:~/svn/tutorialpro01# 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@tutorialpro:~/svn/tutorialpro01# 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 proceed with development in the my_branch branch, switch to the branch path, and create an index.html file.

root@tutorialpro:~/svn/tutorialpro01# cd branches/my_branch/
root@tutorialpro:~/svn/tutorialpro01/branches/my_branch# ls
HelloWorld.html  index.html  readme

Add index.html to version control and commit it to the repository.

root@tutorialpro:~/svn/tutorialpro01/branches/my_branch# svn status
?       index.html
root@tutorialpro:~/svn/tutorialpro01/branches/my_branch# svn add index.html 
A         index.html
root@tutorialpro:~/svn/tutorialpro01/branches/my_branch# svn commit -m "add index.html"
Adding         index.html
Transmitting file data .
Committed revision 10.
root@tutorialpro:~/svn/tutorialpro01/trunk# svn merge ../branches/my_branch/
--- Merging r10 into '.':
A    index.html
--- Recording mergeinfo for merge of r10 into '.':
 G   .

At this point, checking the directory shows that the index.html file created by the my_branch branch is now in the trunk.

root@tutorialpro:~/svn/tutorialpro01/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@tutorialpro:~/svn/tutorialpro01/trunk# svn commit -m "add index.html"
Adding         index.html
Transmitting file data .
Committed revision 11.
❮ Svn Install Home ❯