一、建立一個代碼文件夾mainphp
>[root@node2 svndata]# cd release/ [root@node2 release]# mkdir ./main [root@node2 release]# svn add ./main/ A main [root@node2 release]# svn commit ./main/ -m "zhugan" Adding main Committed revision 2.
二、建立分支node
>[root@node2 release]# svn copy svn://10.0.0.6:/release/main svn://10.0.0.6:/release/beta -m "fenzhichuangjian" Committed revision 3. >[root@node2 release]# svn update Updating '.': A beta Updated to revision 3. [root@node2 release]# ll total 0 drwxr-xr-x. 2 root root 6 Oct 22 17:19 beta drwxr-xr-x. 2 root root 6 Oct 22 17:16 main -rw-r--r--. 1 root root 0 Oct 22 17:10 test.php
三、查看分支狀態svn
[root@node2 release]# svn log ./beta/ ------------------------------------------------------------------------ r4 | admin | 2018-10-22 17:27:46 +0800 (Mon, 22 Oct 2018) | 1 line node3 test files ------------------------------------------------------------------------ r3 | admin | 2018-10-22 17:18:34 +0800 (Mon, 22 Oct 2018) | 1 line fenzhichuangjian ------------------------------------------------------------------------ r2 | admin | 2018-10-22 17:16:45 +0800 (Mon, 22 Oct 2018) | 1 line zhugan ------------------------------------------------------------------------
注間事項:測試
a),建立分支,只能在同一個倉庫內進行,跨倉庫是不行的。會提示svn: No repository found in 'svn://10.0.0.6'code
b),建立分支時,注意加上註釋,否則會報錯
四、分支合併
分別用node2 和node3在beta分支中建立文件或文件夾 並分別提交到svn代碼倉庫ci
>[root@node3 beta]# touch node3_test.log [root@node3 beta]# mkdir node3_test [root@node3 beta]# svn add node3_test.log node3_test A node3_test.log A node3_test [root@node3 beta]# svn ci node3_test node3_test.log -m "node3 test files" Adding node3_test Adding node3_test.log Transmitting file data . Committed revision 4. >[root@node2 beta]# svn update Updating '.': A node3_test A node3_test.log Updated to revision 4. [root@node2 beta]# svn add test_node2.txt node2_test/ A test_node2.txt A node2_test [root@node2 beta]# svn ci test_node2.txt node2_test/ -m "node2 test files" Adding node2_test Adding test_node2.txt Transmitting file data . Committed revision 5. >[root@node2 beta]# ll total 0 drwxr-xr-x. 2 root root 6 Oct 22 17:26 node2_test drwxr-xr-x. 2 root root 6 Oct 22 17:28 node3_test -rw-r--r--. 1 root root 0 Oct 22 17:28 node3_test.log -rw-r--r--. 1 root root 0 Oct 22 17:25 test_node2.txt >[root@node3 beta]# ll total 0 drwxr-xr-x. 2 root root 6 Oct 22 17:28 node2_test drwxr-xr-x. 2 root root 6 Oct 22 17:26 node3_test -rw-r--r--. 1 root root 0 Oct 22 17:26 node3_test.log -rw-r--r--. 1 root root 0 Oct 22 17:28 test_node2.txt
記得update 此時發現 beta文件夾內已經存在生成的測試文件。
五、合併分支到主幹:
1)查找分支版本
方法一同步
[root@node2 release]# cd beta/ [root@node2 beta]# svn log --stop-on-copy ------------------------------------------------------------------------ r4 | admin | 2018-10-22 17:27:46 +0800 (Mon, 22 Oct 2018) | 1 line node3 test files ------------------------------------------------------------------------ r3 | admin | 2018-10-22 17:18:34 +0800 (Mon, 22 Oct 2018) | 1 line fenzhichuangjian ------------------------------------------------------------------------
最後一個r3就是建立分支時候的reversionit
方法二 cd main
命令:svn -q --stop-on-copy 分支URL,這條命令會查詢出自建立分支之後分支上的全部修改,最下面的那個版本號就是咱們要找的版本號.
示例:svn log -q --stop-on-copy svn://10.0.0.6/release/betaio
[root@node2 beta]# svn log -q --stop-on-copy svn://10.0.0.6/release/beta ------------------------------------------------------------------------ r5 | admin | 2018-10-22 17:28:43 +0800 (Mon, 22 Oct 2018) ------------------------------------------------------------------------ r4 | admin | 2018-10-22 17:27:46 +0800 (Mon, 22 Oct 2018) ------------------------------------------------------------------------ r3 | admin | 2018-10-22 17:18:34 +0800 (Mon, 22 Oct 2018) ------------------------------------------------------------------------
2)合併到主幹
命令:svn -r 分支版本號:HEAD 分支的URL
解釋:HEAD爲當前主幹上的最新版本
示例:test
cd main
svn merge -r 5:HEAD svn://192.168.1.177/tags/beta_2009_12_24
查看可知 主幹最新版本爲r2
執行
>[root@node2 main]# svn merge svn://10.0.0.6:/release/beta . --- Merging r3 through r5 into '.': A test_node2.txt A node2_test A node3_test A node3_test.log --- Recording mergeinfo for merge of r3 through r5 into '.': U . [root@node2 main]# ll total 0 drwxr-xr-x. 2 root root 6 Oct 22 17:40 node2_test drwxr-xr-x. 2 root root 6 Oct 22 17:40 node3_test -rw-r--r--. 1 root root 0 Oct 22 17:40 node3_test.log -rw-r--r--. 1 root root 0 Oct 22 17:40 test_node2.txt
分支合併完成 而後提交到代碼庫
>[root@node2 main]# svn ci -m "hebing" Sending . Adding node2_test Adding node3_test Adding node3_test.log Adding test_node2.txt Committed revision 6. 在node3上面執行update 同步 >[root@node3 beta]# cd ../main/ You have new mail in /var/spool/mail/root [root@node3 main]# svn update Updating '.': A test_node2.txt A node2_test A node3_test A node3_test.log U . Updated to revision 6. [root@node3 main]# ll total 0 drwxr-xr-x. 2 root root 6 Oct 22 17:42 node2_test drwxr-xr-x. 2 root root 6 Oct 22 17:42 node3_test -rw-r--r--. 1 root root 0 Oct 22 17:42 node3_test.log -rw-r--r--. 1 root root 0 Oct 22 17:42 test_node2.txt
分支合併完成