SVN Application
一、SVN客户端:TortoiseSvn
下载地址: http://tortoisesvn.net/downloads.html
安装完后重启, 右击就可以使用SVN命令
首先, 从服务器版本库那边 svn Checkout....代码, 放到本地
在checkout目录下(带有.svn文件夹), 主要有以下命令:
常用的 SVN Add... Delete... Rename... Update to revision.... Revert Get lock/Releae lock...
本地Update 出服务器上最新代码
add/delete/edit/rename file 都只是在本地做修改, 要执行 commit 操作才能提交到服务器上。
二、SVN服务器:Subversion
1、安装
下载地址:http://www.visualsvn.com/
个人认为最好用VisualSVN server服务端和TortoiseSVN客户端搭配使用
安装完成后, 点击Window->VisualSVN->VisualSVN Server Manager, 就可以直接使用应用管理器来操作SVN 库
2、SVN 仓库
在Repositories可以CreateNewRepository,新建新的库, 选择库的结构如下:
1)、三个子目录的区别:
tag,一般情况下, 是用来做一个milestone的,不管是不是release,都是一个可用的版本。这里,应该是只读的。更多的是一个显示用的,给人一个可读(readable)的标记。
branch,是用来做并行开发的
trunk, 是主线
2)、仓库转移
(eg: move RepA to RepB)
特定hook类型里面有特定提供的参数,如
REPOS 路径, TXN 事物,USER 用户…
Test.py %REPOS% %TXN% call python/perl..script to achieve more functional control.
示例:
window下, 建pre-commit.bat文件, 放在hooks下, 则该仓库下执行commit时, 必须输入10个字符。 默认安装下,svn可以无comment提交
@echo off setlocal set SVN_BINDIR="D:\Program Files\VisualSVN Server\bin" set REPOS=%1 set TXN=%2 rem check that logmessage contains at least 10 characters %SVN_BINDIR%\svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul if %errorlevel% gtr 0 goto err exit 0 :err echo Empty log messge not allowed.Please log at least 10 characters! 1>&2 exit 1
SVN_BINDIR是svnserver安装路径下的bin文件夹
三、版本控制过程
1、Create a repository
1)Right click in Repositories and create New Repository…
2)Select the second Radio to create a Repository with trunk/baches/tags
3)You can also set access permissions here.
2、Import project to ${repName}/trunk
Go to the project Directory, click svn->import, input the trunk path (get path:copy the trunk URL by right click at trunk folder and click ’copy URL to clipboard’)
3、Check out trunk code to local
New a directory ’svnTrunk’ to store trunk code, then you can excute new Branch/tag, merge etc.
note:不要在branches上先建branch_1文件夹再以此为目录地址来copy,这样会提示Path ‘branches/branch_1‘ already exists,认为branch_1就是已经建好分支, 不能再建),同样方式, 可以创建很多个分支, 并行开发
After new branch in Repository
We can check out the branch code to working copy
Develop………….
Commit code to branch
5. Merge trunk to branch
Note:to avoid a world of difference between branch and trunk, we’d better make branch keep pace with trunk by merge trunk to branch.
Also, we’d better merge trunk to branch before doing merge to trunk
1)Select ‘Merge a range of revision’
2)Input trunk path, Revision range to merge
note: How to decide the merge Revisions:
Click show log to sure what the versions to merge.
3)Resolve the confict, and compile/test_compile the project
4)Commit to RepositoryT1/branches/branch_2 after step5.3 build success.
Continue to develop in branch_2
Commit chages in branch_2 to branch_2 Repository …
Repeat step5 to keep branch sync with trunk when necessary.
Merge branch_2 to trunk as step6
Merge trunk to branch again to Mark the newest version(RecordOnly)
1)Select ‘Reintegrate a branch’
2)Input the branch_1 path to ‘From URL’
3)Click ‘Test merge’ Button to test if it has many conflicts.
4) Resolve the confict, and compile/test_compile the project
5) Commit to RepositoryT1/trunk after step6.4 build success.
7.Copy trunk to tag
Copy trunk to tag when we released a stable version.
8.Merge summary
1)Remember to update to newest version in working copy before merge
2)Step 1-2 Corresponds to ‘version-control step6’
3)Step 3-4 Conrreponds to ‘version-control step5’
4)Do step1-2 frequently to keep branch sync with trunk.
trunk log:
在Log Messages窗口的左下角勾选了"Include merged revisions"你还能看到额外的Merge information:
其中灰色的log, 是branch里自己变化的log , 包括了版本信息。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。