当前位置:K88软件开发文章中心编程工具SVN → 文章内容

SVN 分支

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-14 3:32:43

SVN分支Branch 选项会给开发者创建出另外一条线路。当有人希望开发进程分开成两条不同的线路时,这个选项会非常有用。比如项目 demo 下有两个小组,svn 下有一个 trunk 版。由于客户需求突然变化,导致项目需要做较大改动,此时项目组决定由小组 1 继续完成原来正进行到一半的工作(某个模块),小组 2 进行新需求的开发。那么此时,我们就可以为小组2建立一个分支,分支其实就是 trunk 版(主干线)的一个copy版,不过分支也是具有版本控制功能的,而且是和主干线相互独立的,当然,到最后我们可以通过(合并)功能,将分支合并到 trunk 上来,从而最后合并为一个项目。我们在本地副本中创建一个 my_branch 分支。root@k88:~/svn/k8801# lsbranches tags trunkroot@k88:~/svn/k8801# svn copy trunk/ branches/my_branchA branches/my_branchroot@k88:~/svn/k8801# 查看状态:root@k88:~/svn/k8801# svn statusA + branches/my_branchA + branches/my_branch/HelloWorld.htmlA + branches/my_branch/readme提交新增的分支到版本库。root@k88:~/svn/k8801# svn commit -m "add my_branch" Adding branches/my_branchReplacing branches/my_branch/HelloWorld.htmlAdding branches/my_branch/readmeCommitted revision 9.接着我们就到 my_branch 分支进行开发,切换到分支路径并创建 index.html 文件。root@k88:~/svn/k8801# cd branches/my_branch/root@k88:~/svn/k8801/branches/my_branch# lsHelloWorld.html index.html readme将 index.html 加入版本控制,并提交到版本库中。root@k88:~/svn/k8801/branches/my_branch# svn status? index.htmlroot@k88:~/svn/k8801/branches/my_branch# svn add index.html A index.htmlroot@k88:~/svn/k8801/branches/my_branch# svn commit -m "add index.html"Adding index.htmlTransmitting file data .Committed revision 10.切换到 trunk,执行 svn update,然后将 my_branch 分支合并到 trunk 中。root@k88:~/svn/k8801/trunk# svn merge ../branches/my_branch/--- Merging r10 into '.':A index.html--- Recording mergeinfo for merge of r10 into '.': G .此时查看目录,可以看到 trunk 中已经多了 my_branch 分支创建的 index.html 文件。root@k88:~/svn/k8801/trunk# lltotal 16drwxr-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将合并好的 trunk 提交到版本库中。root@k88:~/svn/k8801/trunk# svn commit -m "add index.html"Adding index.htmlTransmitting file data .Committed revision 11.

SVN 分支