zoukankan      html  css  js  c++  java
  • 【SVN】SVN的trunk、branches、tag的使用以及分支的概念

      SVN命令参考:    https://www.cnblogs.com/wlsxmhz/p/5775393.html

    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.服务器端创建一个仓库

    [root@VM_0_12_centos repository]# svnadmin create ./danger  #创建仓库
    [root@VM_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目录:

    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject
    $ svn co svn://qiaoliqiang.cn:3690/danger  #检出项目,等价于svn checkout url
    Checked out revision 0.
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject
    $ ls
    danger/

    创建三个目录并且提交到SVN服务器:

    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject
    $ cd danger/
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ ls
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ mkdir trunk branches tags      #创建三个目录
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ ls
    branches/  tags/  trunk/
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ svn add *      #添加到索引库
    A         branches
    A         tags
    A         trunk
    
    Administrator@MicroWin10-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正常开发并且提交到服务器:

    Administrator@MicroWin10-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
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ svn ci -m "add a file"      #提交到服务器
    Adding         trunkmyProject
    Adding         trunkmyProject	est.txt
    Transmitting file data .
    Committed revision 2.

    5.我们创建一个分支并且切换到新分支:

    Administrator@MicroWin10-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

    Administrator@MicroWin10-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'
    
    Administrator@MicroWin10-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.
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ ls
    myProject/

    当然我们可以切换到主干分支

    Administrator@MicroWin10-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.在新建的分支修改文件

    新建的分支修改文件并且提交

    Administrator@MicroWin10-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
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ svn ci -m "qlqbranch modify test.txt"
    Sending        myProject	est.txt
    Transmitting file data .
    Committed revision 4.

    切换到主分支查看文件是否是修改之前的文件:

    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ svn switch svn://qiaoliqiang.cn:3690/danger/trunk  --ignore-ancestry  #切换到主干分支
    U    myProject	est.txt
    Updated to revision 4.
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger
    $ cat ./myProject/test.txt      #读取文件
    111
    
    Administrator@MicroWin10-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.
    
    Administrator@MicroWin10-1535 MINGW64 ~/Desktop/svnproject/danger      #读取文件
    $ cat ./myProject/test.txt
    111
    111
    111
    111
    111
    111
    111

    7. 合并qlqbranch到主干trunk分支

    • 切换到主干分支并查看是否切换成功
    Administrator@MicroWin10-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作为旧版本合并)
    Administrator@MicroWin10-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分支到主干分支
    Administrator@MicroWin10-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
    Administrator@MicroWin10-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查看
    Administrator@MicroWin10-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.
    
    Administrator@MicroWin10-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)
  • 相关阅读:
    快速排序学习
    转载 libSVM介绍(二)
    支持向量机: Maximum Margin Classifier
    联发科笔试题之字符编码
    研究1
    在OnLButtonDown获取其他控件被点击的消息
    希尔排序学习
    快速排序
    别人的string的实现,有时间好好学习下
    完成动态根据类别动态填充区域颜色
  • 原文地址:https://www.cnblogs.com/qlqwjy/p/9336737.html
Copyright © 2011-2022 走看看