[root@ok svndata]# svn co svn://192.168.1.111/app01
# checkout项目到本机
开始规划我们的svn项目目录:
[root@ok svndata]# tree app01/
app01/ #项目根目录
├── branches #其他分支
│ ├── iterative- #迭代分支
│ ├── iterative--feature1 #基于迭代分支的特性1分支
│ └── iterative--feature2 #基于迭代分支的特性2分支
├── tags
└── trunk #主干分支 directories, 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 branches
A branches
[root@ok app01]# svn ci -m "创建分支目录"
Adding branches Committed revision .
[root@ok app01]# svn update
At revision .
创建分支的方式一:
[root@ok app01]# svn cp trunk/ branches/iterative-
A branches/iterative-
[root@ok app01]# svn ci -m "创建二期迭代分支"
Adding branches/iterative- Committed revision .
创建分分支的方式二:
[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 | -- :: + (Fri, Aug ) | line
Changed paths:
A /branches/iterative- (from /trunk:) 创建二期迭代分支
基于迭代分支创建特性分支:
因为一次迭代开发可能包含很多新功能,面这些个功能可以由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 .
[root@ok app01]# svn update
A branches/iterative--feature-say-hi
A branches/iterative--feature-say-hi/hello.py
Updated to revision .
[root@ok app01]# svn ci -m "2期需求:say hi功能"
[root@ok app01]# svn update
At revision .
[root@ok app01]# svn log -v
------------------------------------------------------------------------
r12 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
A /branches/iterative--feature-say-hi (from /branches/iterative-:) 2期需求:say hi功能
------------------------------------------------------------------------
r11 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
A /branches/iterative- (from /trunk:) 创建二期迭代分支
------------------------------------------------------------------------
r10 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
D /branches/iterative-
实现特性功能:
[root@ok app01]# echo "加入代码实现一些功能!!!">branches/iterative--feature-say-hi/hello.py
[root@ok app01]# svn commit -m "say hi 功能"
Sending branches/iterative--feature-say-hi/hello.py
Transmitting file data .
Committed revision .
[root@ok app01]# svn update
At revision .
[root@ok app01]# svn log -v branches/iterative--feature-say-hi/hello.py
------------------------------------------------------------------------
r13 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
M /branches/iterative--feature-say-hi/hello.py say hi 功能
------------------------------------------------------------------------
r12 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
A /branches/iterative--feature-say-hi (from /branches/iterative-:) 2期需求:say hi功能
------------------------------------------------------------------------
r11 | svnroot | -- :: + (Fri, Aug ) | line
Changed paths:
A /branches/iterative- (from /trunk:) 创建二期迭代分支
合并回迭代分支
[root@ok app01]# svn mkdir branches/{iterative--feature1,iterative--feature2}
A branches/iterative--feature1
A branches/iterative--feature2
[root@ok app01]# svn ci -m "基于迭代分支的特性1和2分支"
Adding branches/iterative--feature1
Adding branches/iterative--feature2 Committed revision .
[root@ok app01]# cd branches/iterative--feature1/
[root@ok iterative--feature1]# svn merge svn://192.168.1.111/app01/branches/iterative-2
[root@ok iterative--feature1]# svn commit -m "合并迭代分支的修改"
Sending iterative--feature1 Committed revision .
//自测,没问是后,合并回迭代分支
[root@ok branches]# cd iterative-
[root@ok iterative-]# 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-]# svn status
M .
M hello.py
[root@ok iterative-]# svn diff Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
Merged /branches/iterative--feature-say-hi:r12- Index: hello.py
===================================================================
--- hello.py (revision )
+++ hello.py (working copy)
@@ -, + @@
+加入代码实现一些功能!!!
[root@ok iterative-]# svn ci -m "合并回迭代分支"
Sending iterative-
Sending iterative-/hello.py
Transmitting file data .
Committed revision .
使用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-]# svn rm svn://192.168.1.111/app01/branches/iterative-2-feature-say-hi -m ""
打一个tag:
[root@ok app01]# svn mkdir tags
A tags
[root@ok app01]# svn ci -m ""
Adding tags Committed revision .
[root@ok app01]# svn copy svn://192.168.1.111/app01/trunk svn://192.168.1.111/app01/tags/1.0 -m "1.0 Released" Committed revision .
[root@ok app01]# tree
.
├── branches
│ ├── iterative-
│ │ └── hello.py
│ ├── iterative--feature1
│ ├── iterative--feature2
│ └── iterative--feature-say-hi
│ └── hello.py
├── tags
│ └── 1.0
│ └── hello.py
└── trunk
└── hello.py directories, files
[root@ok app01]# cat tags/1.0/hello.py
进行了一些修改 实现了要求达到的功能!!
------------------------------------------
创建分支:
[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_feature001
A br_feature001/hello.py
Checked out revision .
合并主干上的最新代码到分支上
[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 eligible
r18
在分支上的开发结束,分支上的代码需要合并到主干,如下步骤:
[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 | -- :: + (Fri, Aug ) | line ------------------------------------------------------------------------
r18 | svnroot | -- :: + (Fri, Aug ) | line 12k
------------------------------------------------------------------------
r7 | svnroot | -- :: + (Fri, Aug ) | line init
------------------------------------------------------------------------
[root@ok trunk]# svn -r : 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 .
可以看出,就是简单的复制动做。