SVN 中trunk、branches、tags都啥意思?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SVN 中trunk、branches、tags都啥意思?相关的知识,希望对你有一定的参考价值。

1、trunk是主分支,是日常开发进行的地方。

2、branches是分支。一些阶段性的release版本,这些版本是可以继续进行开发和维护的,则放在branches目录中。又比如为不同用户客制化的版本,也可以放在分支中进行开发。

3、tags目录一般是只读的,这里存储阶段性的发布版本,只是作为一个里程碑的版本进行存档。

扩展资料

在SVN中建立Branch和tag的方法如下: 

1.选择Branch和tag.

2.在出来的界面中的ToURL中填上URL,一般是svn://IP/Project/branches/branch-1,这样就建立了一个branch-1的branch.建立tag是一样的操作,只不过URL一般是svn://IP/Project/tags/tag-1 

3.后面的Createcopyfrom是用于选择从你当前的workingbase中的哪个版本中建立Branch和tag,可以根据自己的选择来订制,一般选择HeadRevision 

参考资料:svn-百度百科 svn中文官网

参考技术A 1.trunk是主分支,是日常开发进行的地方。

2.branches是分支。一些阶段性的release版本,这些版本是可以继续进行开发和维护的,则放在branches目录中。又比如为不同用户客制化的版本,也可以放在分支中进行开发。

3.tags目录一般是只读的,这里存储阶段性的发布版本,只是作为一个里程碑的版本进行存档。
注意:svn并没有明确的规范,更多的还是用户自己的习惯。
下面是详细介绍:
比如一个项目有main.cpp, common.h两个文件,假设目前在开发的是最新的3.0版本,而且1.0/2.0版本也在进行维护,那么项目树将类似如下样子:
project
|
+-- trunk
+ |
+ +----- main.cpp (3.0版本的最新文件)
+ +----- common.h
+
+-- branches
+ |
+ +-- r1.0
+ + |
+ + +---- main.cpp (1.x版本的最新文件)
+ + +---- common.h
+ +
+ +-- r2.0
+ |
+ +---- main.cpp (2.x版本的最新文件)
+ +---- common.h
+
+-- tags (此目录只读)
|
+-- r1.0
+ |
+ +---- main.cpp (1.0版本的发布文件)
+ +---- common.h
+
+-- r1.1
+ |
+ +---- main.cpp (1.1版本的发布文件)
+ +---- common.h
+
+-- r1.2
+ |
+ +---- main.cpp (1.2版本的发布文件)
+ +---- common.h
+
+-- r1.3
+ |
+ +---- main.cpp (1.3版本的发布文件)
+ +---- common.h
+
+-- r2.0
+ |
+ +---- main.cpp (2.0版本的发布文件)
+ +---- common.h
+
+-- r2.1
|
+---- main.cpp (2.1版本的发布文件)
+---- common.h
要使用这样的文件夹结构,在建立项目版本库时,可首先建好项目文件夹,并在其中建立trunk, branches, tags三个空的子目录,再将项目文件夹连同这三个子目录一起导入版本库。
这样在trunk中开始进行开发,当需要建立branch或tag时,使用SVN的copy操作进行。
其中tags目录需要只读,可以使用SVN中的authz文件控制该目录的访问权限为只读。本回答被提问者和网友采纳
参考技术B trunk、 干线。
branches、 分支
tags、 标签

???SVN???SVN???trunk???branches???tag??????????????????????????????

?????????top   ????????????   rom   code   strong   ??????   info   this   svn?????????   

svn????????????????????????????????????????????????trunk???branches???tags?????????????????????trunk??????????????????????????????branches???????????????????????????tags???????????????????????????????????????????????????

tags????????????branches???????????????????????????????????????????????????branches??????????????????????????????????????????tags??????????????????????????????????????????????????????

??????tags????????????????????????????????????????????????Release0.91???Release1.23???

1?????????????????????????????????????????????????????????????????????????????????trunk???branches???tags????????????

?????????????????????????????????????????????????????????????????????????????????trunk, branches, tags?????????????????????????????????trunk?????????????????????

   trunk????????????????????????????????????????????????

   branches??????????????????????????????release????????????????????????????????????????????????????????????????????????branches????????????????????????????????????????????????????????????????????????????????????????????????

   tags?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

2.????????????????????????????????????????????????

1.??????????????????????????????

[[email protected]_0_12_centos repository]# svnadmin create ./danger??????#????????????
[[email protected]_0_12_centos repository]# ls ./danger/????????????????????????#??????????????????
conf  db  format  hooks  locks  README.txt

 

 

2.???????????????????????????????????????????????????????????????(??????conf????????????????????????:)

authz???????????????????????????????????????????????????????????????

passwd?????????????????????????????????????????????

svnserve.conf???svn?????????????????????

 

 

authz???????????????????????????????????????r??????????????????w???????????????:

??????????????????

 

 

passwd???????????????????????????????????????

??????????????????

?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

?????? = ??????

?????????admin = 123456

 

??????svnserve.conf????????????????????????????????????????????????????????????

??????????????????

 

3.?????????????????????????????????trunk???tags???branches??????:

[email protected]1535 MINGW64 ~/Desktop/svnproject
$ svn co svn://qiaoliqiang.cn:3690/danger??????#????????????????????????svn checkout url
Checked out revision 0.

[email protected]-1535 MINGW64 ~/Desktop/svnproject
$ ls
danger/

 

 

?????????????????????????????????SVN?????????:

[email protected]1535 MINGW64 ~/Desktop/svnproject
$ cd danger/

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ ls

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ mkdir trunk branches tags??????????????????#??????????????????

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ ls
branches/  tags/  trunk/

 

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn add *??????????????????#??????????????????
A         branches
A         tags
A         trunk

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn ci -m "add 3 dirs"??????#?????????????????????????????????svn commit -m "xxx"
Adding         branches
Adding         tags
Adding         trunk

Committed revision 1.

 

 

4.????????????trunk???????????????trunk????????????????????????????????????:

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn diff??????????????????#?????????????????????
Index: trunk/myProject/test.txt
===================================================================
--- trunk/myProject/test.txt    (revision 0)
+++ trunk/myProject/test.txt    (working copy)
@@ -0,0 +1 @@
+111

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn ci -m "add a file"??????????????????#??????????????????
Adding         trunkmyProject
Adding         trunkmyProject	est.txt
Transmitting file data .
Committed revision 2.

 

 

5.????????????????????????????????????????????????:

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn cp svn://qiaoliqiang.cn:3690/danger/trunk svn://qiaoliqiang.cn:3690/danger/branches/qlqbranch -m "add qlqbranch"??????#????????????

Committed revision 3.

 

svn cp ?????????  svn copy

 

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/branches/qlqbranch
svn: E195012: Path ???.??? does not share common version control ancestry with the requested switch location.  Use --ignore-ancestry to disable this check.
svn: E195012: ???svn://qiaoliqiang.cn/danger/branches/qlqbranch??? shares no common ancestry with ???C:UsersAdministratorDesktopsvnprojectdanger???

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/branches/qlqbranch  --ignore-ancestry??????#???????????????qlqbranch
D    tags
D    trunk
D    branches
A    myProject
A    myProject	est.txt
Updated to revision 3.

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ ls
myProject/

 

 

???????????????????????????????????????

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/trunk  --ignore-ancestry    #??????????????????

 

 

 

??????????????????svn info????????????????????????????????????

$ svn info    #??????url??????????????????????????????
Path: .
Working Copy Root Path: C:UsersAdministratorDesktopsvnprojectdanger
URL: svn://qiaoliqiang.cn/danger/branches/qlqbranch??????
Relative URL: ^/branches/qlqbranch
Repository Root: svn://qiaoliqiang.cn/danger
Repository UUID: 5fd66061-fba7-44bc-bfef-b078c6e4d2c6
Revision: 4
Node Kind: directory
Schedule: normal
Last Changed Author: qiaolq
Last Changed Rev: 4
Last Changed Date: 2018-07-19 16:03:42 +0800 (????, 19 7?? 2018)

 

 

6.??????????????????????????????

???????????????????????????????????????

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn diff
Index: myProject/test.txt
===================================================================
--- myProject/test.txt  (revision 3)
+++ myProject/test.txt  (working copy)
@@ -1 +1,7 @@
 111
+111
+111
+111
+111
+111
+111

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn ci -m "qlqbranch modify test.txt"
Sending        myProject	est.txt
Transmitting file data .
Committed revision 4.

 

 

????????????????????????????????????????????????????????????:

[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/trunk  --ignore-ancestry??????#?????????????????????
U    myProject	est.txt
Updated to revision 4.

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ cat ./myProject/test.txt??????????????????#????????????
111

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/branches/qlqbranch  --ignore-ancestry??????#?????????qlqbranch??????
U    myProject	est.txt
Updated to revision 4.

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger??????????????????#????????????
$ cat ./myProject/test.txt
111
111
111
111
111
111
111

 

 

7. ??????qlqbranch?????????trunk??????

  • ????????????????????????????????????????????????
[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/trunk  --ignore-ancestry   #????????????
At revision 4.

 

$ svn info??????#??????????????????url?????????url????????????????????????
Path: .
Working Copy Root Path: C:UsersAdministratorDesktopsvnprojectdanger
URL: svn://qiaoliqiang.cn/danger/trunk
Relative URL: ^/trunk
Repository Root: svn://qiaoliqiang.cn/danger
Repository UUID: 5fd66061-fba7-44bc-bfef-b078c6e4d2c6
Revision: 4
Node Kind: directory
Schedule: normal
Last Changed Author: qiaolq
Last Changed Rev: 2
Last Changed Date: 2018-07-19 15:54:21 +0800 (????, 19 7?? 2018)

 

 

  • ????????????????????????????????????(r3???????????????????????????????????????3???????????????????????????3?????????????????????)
[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn log --verbose --stop-on-copy | tail -10
   M /branches/qlqbranch/myProject/test.txt

qlqbranch modify test.txt
------------------------------------------------------------------------
r3 | qiaolq | 2018-07-19 15:57:37 +0800 (????, 19 7?? 2018) | 1 line
Changed paths:
   A /branches/qlqbranch (from /trunk:2)

add qlqbranch

 

 

  • ??????qlqbranch?????????????????????
[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn merge -r 3:4 svn://qiaoliqiang.cn/danger/branches/qlqbranch   #???????????????svn merge oldver:newver oldurl

 

 

8.????????????tag(??????copy)

  • ??????tag
[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn copy svn://qiaoliqiang.cn:3690/danger/trunk svn://qiaoliqiang.cn:3690/danger/tags/release-1.0 -m "1.0released"

Committed revision 5.

 

 

  • ?????????tag??????
[email protected]1535 MINGW64 ~/Desktop/svnproject/danger
$ svn switch svn://qiaoliqiang.cn:3690/danger/tags/release-1.0  --ignore-ancestry   #???????????????tag
U    myProject	est.txt
Updated to revision 5.

[email protected]-1535 MINGW64 ~/Desktop/svnproject/danger
$ svn info??????????????????#????????????????????????
Path: .
Working Copy Root Path: C:UsersAdministratorDesktopsvnprojectdanger
URL: svn://qiaoliqiang.cn/danger/tags/release-1.0
Relative URL: ^/tags/release-1.0
Repository Root: svn://qiaoliqiang.cn/danger
Repository UUID: 5fd66061-fba7-44bc-bfef-b078c6e4d2c6
Revision: 5
Node Kind: directory
Schedule: normal
Last Changed Author: qiaolq
Last Changed Rev: 5
Last Changed Date: 2018-07-19 16:38:49 +0800 (????, 19 7?? 2018)

 

以上是关于SVN 中trunk、branches、tags都啥意思?的主要内容,如果未能解决你的问题,请参考以下文章

SVN 主干(trunk)分支(branch )标记(tag)

SVN中的trunk branches tags

SVN 中trunk、branches、tags都啥意思?

svn中的Trunk,branches,tags深度理解

???SVN???SVN???trunk???branches???tag??????????????????????????????

SVN版本管理trunk及branch相关merge操作