首页 > 代码库 > svn分支管理进行迭代开发
svn分支管理进行迭代开发
[root@ok svndata]# svn co svn://192.168.1.111/app01# checkout项目到本机
开始规划我们的svn项目目录:
[root@ok svndata]# tree app01/ app01/ #项目根目录├── branches #其他分支│ ├── iterative-2 #迭代分支│ ├── iterative-2-feature1 #基于迭代分支的特性1分支│ └── iterative-2-feature2 #基于迭代分支的特性2分支├── tags└── trunk #主干分支6 directories, 0 files
主干分支上创建第一个代码文件:
[root@ok app01]# svn mkdir trunk
A trunk
[root@ok app01]# touch trunk/hello.py
[root@ok app01]# svn add trunk/hello.py
A trunk/hello.py
[root@ok app01]# svn ci -m "init"
Adding trunk
Adding trunk/hello.py
Transmitting file data .
Committed revision 7.
[root@ok app01]# svn update
At revision 7.
创建我们的第一个迭代分支:
[root@ok app01]# svn mkdir branchesA branches[root@ok app01]# svn ci -m "创建分支目录"Adding branchesCommitted revision 8.[root@ok app01]# svn updateAt revision 8.
创建分分支的方式一:
[root@ok app01]# svn cp trunk/ branches/iterative-2A branches/iterative-2[root@ok app01]# svn ci -m "创建二期迭代分支"Adding branches/iterative-2Committed revision 9.
创建分分支的方式二:
[root@ok app01]# svn cp svn://192.168.1.111/app01/trunk \> svn://192.168.1.111/app01/branches/iterative-2 \> -m "创建二期迭代分支"
注意一定要svn update 否则可能会看不到更新log[root@ok app01]# svn update
[root@ok app01]# svn log -v------------------------------------------------------------------------r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: A /branches/iterative-2 (from /trunk:8)创建二期迭代分支
基于迭代分支创建特性分支:
因为一次迭代开发可能包含很多新功能,面这些个功能可以由N个开发人员来并行开发。所以最佳方案是每个功能点再建一个分支出来,实现之后再合并回二期迭代分支。
[root@ok app01]# svn cp svn://192.168.1.111/app01/branches/iterative-2 \> svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi \> -m "2期需求:say hi功能"Committed revision 12.[root@ok app01]# svn updateA branches/iterative-2-feature-say-hiA branches/iterative-2-feature-say-hi/hello.pyUpdated to revision 12.[root@ok app01]# svn ci -m "2期需求:say hi功能"[root@ok app01]# svn updateAt revision 12.[root@ok app01]# svn log -v------------------------------------------------------------------------r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: A /branches/iterative-2-feature-say-hi (from /branches/iterative-2:11)2期需求:say hi功能------------------------------------------------------------------------r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: A /branches/iterative-2 (from /trunk:8)创建二期迭代分支------------------------------------------------------------------------r10 | svnroot | 2016-08-26 12:21:48 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: D /branches/iterative-2
实现特性功能:
[root@ok app01]# echo "加入代码实现一些功能!!!">branches/iterative-2-feature-say-hi/hello.py [root@ok app01]# svn commit -m "say hi 功能"Sending branches/iterative-2-feature-say-hi/hello.pyTransmitting file data .Committed revision 13.[root@ok app01]# svn updateAt revision 13.[root@ok app01]# svn log -v branches/iterative-2-feature-say-hi/hello.py ------------------------------------------------------------------------r13 | svnroot | 2016-08-26 12:38:06 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: M /branches/iterative-2-feature-say-hi/hello.pysay hi 功能------------------------------------------------------------------------r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: A /branches/iterative-2-feature-say-hi (from /branches/iterative-2:11)2期需求:say hi功能------------------------------------------------------------------------r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 lineChanged paths: A /branches/iterative-2 (from /trunk:8)创建二期迭代分支
合并回迭代分支
[root@ok app01]# svn mkdir branches/{iterative-2-feature1,iterative-2-feature2}A branches/iterative-2-feature1A branches/iterative-2-feature2[root@ok app01]# svn ci -m "基于迭代分支的特性1和2分支"Adding branches/iterative-2-feature1Adding branches/iterative-2-feature2Committed revision 14.
[root@ok app01]# cd branches/iterative-2-feature1/[root@ok iterative-2-feature1]# svn merge svn://192.168.1.111/app01/branches/iterative-2[root@ok iterative-2-feature1]# svn commit -m "合并迭代分支的修改"Sending iterative-2-feature1Committed revision 15.//自测,没问是后,合并回迭代分支[root@ok branches]# cd iterative-2[root@ok iterative-2]# svn merge --reintegrate svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi--- Merging differences between repository URLs into ‘.‘:U hello.py[root@ok iterative-2]# svn status M .M hello.py[root@ok iterative-2]# svn diffProperty changes on: .___________________________________________________________________Added: svn:mergeinfo Merged /branches/iterative-2-feature-say-hi:r12-15Index: hello.py===================================================================--- hello.py (revision 13)+++ hello.py (working copy)@@ -0,0 +1 @@+加入代码实现一些功能!!![root@ok iterative-2]# svn ci -m "合并回迭代分支"Sending iterative-2Sending iterative-2/hello.pyTransmitting file data .Committed revision 16.
使用reintegrate合并后,迭代分支并没有保存特 性分支的提交历史(但是在branches目录下,能看到完整的提交历史)
迭代分支合并到 trunk 中
[root@ok trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/iterative-2
--- Merging differences between repository URLs into ‘.‘:
U hello.py
U .
[root@ok iterative-2]# svn diff
Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
Merged /branches/iterative-2-feature-say-hi:r30-33
Index: hello.py
===================================================================
--- hello.py (revision 31)
+++ hello.py (working copy)
@@ -0,0 +1 @@
+进行了一些修改 实现了要求达到的功能!!
[root@ok trunk]# svn ci -m "合并到turnk"
Sending trunk
Sending trunk/hello.py
Transmitting file data .
Committed revision 36.
[root@ok trunk]# svn update
At revision 36.
[root@ok trunk]# svn log
------------------------------------------------------------------------
r36 | svnroot | 2016-08-26 19:16:30 +0800 (Fri, 26 Aug 2016) | 1 line
合并到turnk
------------------------------------------------------------------------
r27 | svnroot | 2016-08-26 18:40:48 +0800 (Fri, 26 Aug 2016) | 1 line
init
------------------------------------------------------------------------
删除特性分支
[root@ok iterative-2]# svn rm svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi -m ""
------------------------------------------
创建分支:
[root@ok branches]# svn cp -m "create branch" svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/branches/br_feature001
获得分支:
[root@ok branches]# svn co svn://192.168.1.111/app01/branches/br_feature001A br_feature001/hello.pyChecked out revision 17.
合并主干上的最新代码到分支上
[root@ok br_feature001]# svn merge svn://192.168.1.111/app01/trunk
测试如下:
[root@ok br_feature001]# cat hello.py [root@ok br_feature001]# svn merge svn://192.168.1.111/app01/trunk--- Merging r18 into ‘.‘:U hello.py [root@ok br_feature001]# cat hello.py 12k
如果需要预览该刷新操做,可以使用svn mergeinfo:
[root@ok trunk]# svn mergeinfo svn://192.168.1.111/app01/trunk --show-revs eligibler18
在分支上的开发结束,分支上的代码需要合并到主干,如下步骤:
[root@ok br_feature001]# cat hello.py 12k[root@ok br_feature001]# svn status M .M hello.py#末把分支合并到主干之前,查看代码:[root@ok br_feature001]# cat ../../trunk/hello.py 12k[root@ok trunk]# cat hello.py 12k更新主干内容!!![root@ok trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/br_feature001
分支合并到主干中完成后应当删该分支,因为在svn中该分支已经不能进行刷新也不能合并到主干。
[root@ok trunk]# svn log------------------------------------------------------------------------r19 | svnroot | 2016-08-26 16:10:20 +0800 (Fri, 26 Aug 2016) | 1 line------------------------------------------------------------------------r18 | svnroot | 2016-08-26 15:57:32 +0800 (Fri, 26 Aug 2016) | 1 line12k------------------------------------------------------------------------r7 | svnroot | 2016-08-26 12:05:49 +0800 (Fri, 26 Aug 2016) | 1 lineinit------------------------------------------------------------------------[root@ok trunk]# svn -r 18:19 merge svn://192.168.1.111/app01/trunk
建立tags
产品开发已经基本完成,并且通过很严格的测试,这时候我们就想发布给客户使用,发布为1.0版本
[root@ok app01]# svn copy svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/1.0 -m "Release 1.0"Committed revision 20.
可以看出,就是简单的复制动做。
svn分支管理进行迭代开发
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。