[[email protected] svndata]# svn co svn://192.168.1.111/app01 # checkout项目到本机
开始规划我们的svn项目目录:
[[email protected] svndata]# tree app01/ app01/ #项目根目录 ├── branches #其他分支 │ ├── iterative-2 #迭代分支 │ ├── iterative-2-feature1 #基于迭代分支的特性1分支 │ └── iterative-2-feature2 #基于迭代分支的特性2分支 ├── tags └── trunk #主干分支 6 directories, 0 files
主干分支上创建第一个代码文件:
[[email protected] app01]# svn mkdir trunkA trunk[[email protected] app01]# touch trunk/hello.py [[email protected] app01]# svn add trunk/hello.py A trunk/hello.py[[email protected] app01]# svn ci -m "init"Adding trunkAdding trunk/hello.pyTransmitting file data .Committed revision 7.[[email protected] app01]# svn updateAt revision 7.
创建我们的第一个迭代分支:
[[email protected] app01]# svn mkdir branches A branches [[email protected] app01]# svn ci -m "创建分支目录" Adding branches Committed revision 8. [[email protected] app01]# svn update At revision 8.
创建分分支的方式一:
[[email protected] app01]# svn cp trunk/ branches/iterative-2 A branches/iterative-2 [[email protected] app01]# svn ci -m "创建二期迭代分支" Adding branches/iterative-2 Committed revision 9.
创建分分支的方式二:
[[email protected] app01]# svn cp svn://192.168.1.111/app01/trunk \ > svn://192.168.1.111/app01/branches/iterative-2 \ > -m "创建二期迭代分支"
注意一定要svn update 否则可能会看不到更新log [[email protected] app01]# svn update
[[email protected] app01]# svn log -v ------------------------------------------------------------------------ r11 | svnroot | 2016-08-26 12:22:45 +0800 (Fri, 26 Aug 2016) | 1 line Changed paths: A /branches/iterative-2 (from /trunk:8) 创建二期迭代分支
基于迭代分支创建特性分支:
因为一次迭代开发可能包含很多新功能,面这些个功能可以由N个开发人员来并行开发。所以最佳方案是每个功能点再建一个分支出来,实现之后再合并回二期迭代分支。
[[email protected] 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. [[email protected] app01]# svn update A branches/iterative-2-feature-say-hi A branches/iterative-2-feature-say-hi/hello.py Updated to revision 12. [[email protected] app01]# svn ci -m "2期需求:say hi功能" [[email protected] app01]# svn update At revision 12. [[email protected] app01]# svn log -v ------------------------------------------------------------------------ r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 line Changed 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 line Changed paths: A /branches/iterative-2 (from /trunk:8) 创建二期迭代分支 ------------------------------------------------------------------------ r10 | svnroot | 2016-08-26 12:21:48 +0800 (Fri, 26 Aug 2016) | 1 line Changed paths: D /branches/iterative-2
实现特性功能:
[[email protected] app01]# echo "加入代码实现一些功能!!!">branches/iterative-2-feature-say-hi/hello.py [[email protected] app01]# svn commit -m "say hi 功能" Sending branches/iterative-2-feature-say-hi/hello.py Transmitting file data . Committed revision 13. [[email protected] app01]# svn update At revision 13. [[email protected] 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 line Changed paths: M /branches/iterative-2-feature-say-hi/hello.py say hi 功能 ------------------------------------------------------------------------ r12 | svnroot | 2016-08-26 12:34:40 +0800 (Fri, 26 Aug 2016) | 1 line Changed 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 line Changed paths: A /branches/iterative-2 (from /trunk:8) 创建二期迭代分支
合并回迭代分支
[[email protected] app01]# svn mkdir branches/{iterative-2-feature1,iterative-2-feature2} A branches/iterative-2-feature1 A branches/iterative-2-feature2 [[email protected] app01]# svn ci -m "基于迭代分支的特性1和2分支" Adding branches/iterative-2-feature1 Adding branches/iterative-2-feature2 Committed revision 14.
[[email protected] app01]# cd branches/iterative-2-feature1/ [[email protected] iterative-2-feature1]# svn merge svn://192.168.1.111/app01/branches/iterative-2 [[email protected] iterative-2-feature1]# svn commit -m "合并迭代分支的修改" Sending iterative-2-feature1 Committed revision 15. //自测,没问是后,合并回迭代分支 [[email protected] branches]# cd iterative-2 [[email protected] 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 [[email protected] iterative-2]# svn status M . M hello.py [[email protected] iterative-2]# svn diff Property changes on: . ___________________________________________________________________ Added: svn:mergeinfo Merged /branches/iterative-2-feature-say-hi:r12-15 Index: hello.py =================================================================== --- hello.py (revision 13) +++ hello.py (working copy) @@ -0,0 +1 @@ +加入代码实现一些功能!!! [[email protected] iterative-2]# svn ci -m "合并回迭代分支" Sending iterative-2 Sending iterative-2/hello.py Transmitting file data . Committed revision 16.
使用reintegrate合并后,迭代分支并没有保存特 性分支的提交历史(但是在branches目录下,能看到完整的提交历史)
迭代分支合并到 trunk 中
[[email protected] trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/iterative-2--- Merging differences between repository URLs into ‘.‘:U hello.py U .[[email protected] 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 @@+进行了一些修改 实现了要求达到的功能!![[email protected] trunk]# svn ci -m "合并到turnk"Sending trunkSending trunk/hello.pyTransmitting file data .Committed revision 36.[[email protected] trunk]# svn updateAt revision 36.[[email protected] 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------------------------------------------------------------------------
删除特性分支
[[email protected] iterative-2]# svn rm svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi -m ""
------------------------------------------
创建分支:
[[email protected] branches]# svn cp -m "create branch" svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/branches/br_feature001
获得分支:
[[email protected] branches]# svn co svn://192.168.1.111/app01/branches/br_feature001 A br_feature001/hello.py Checked out revision 17.
合并主干上的最新代码到分支上
[[email protected] br_feature001]# svn merge svn://192.168.1.111/app01/trunk
测试如下:
[[email protected] br_feature001]# cat hello.py [[email protected] br_feature001]# svn merge svn://192.168.1.111/app01/trunk --- Merging r18 into ‘.‘: U hello.py [[email protected] br_feature001]# cat hello.py 12k
如果需要预览该刷新操做,可以使用svn mergeinfo:
[[email protected] trunk]# svn mergeinfo svn://192.168.1.111/app01/trunk --show-revs eligible r18
在分支上的开发结束,分支上的代码需要合并到主干,如下步骤:
[[email protected] br_feature001]# cat hello.py 12k [[email protected] br_feature001]# svn status M . M hello.py #末把分支合并到主干之前,查看代码: [[email protected] br_feature001]# cat ../../trunk/hello.py 12k [[email protected] trunk]# cat hello.py 12k 更新主干内容!!! [[email protected] trunk]# svn merge --reintegrate svn://192.168.1.111/app01/branches/br_feature001
分支合并到主干中完成后应当删该分支,因为在svn中该分支已经不能进行刷新也不能合并到主干。
[[email protected] 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 line 12k ------------------------------------------------------------------------ r7 | svnroot | 2016-08-26 12:05:49 +0800 (Fri, 26 Aug 2016) | 1 line init ------------------------------------------------------------------------ [[email protected] trunk]# svn -r 18:19 merge svn://192.168.1.111/app01/trunk
建立tags
产品开发已经基本完成,并且通过很严格的测试,这时候我们就想发布给客户使用,发布为1.0版本
[[email protected] 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.
可以看出,就是简单的复制动做。
时间: 2024-10-06 00:30:51