SVN安装和使用
SVN的安装
访问
SVN网站下载你所需版本的安装包。以Linux为例,安装过程为依次执行以下步骤:
rpm -ivh apr-0.9.5-0.2.i386.rpmrpm -ivh apr-util-0.9.5-0.1.i386.rpmrpm -ivh neon-0.24.7-1.i386.rpmrpm -ivh subversion-1.1.1-1.rh80.i386.rpm
SVN安装包的基本命令
svn | The command-line client program. |
svnversion | A program for reporting the state (in terms of revisions of the items present) of a working copy. |
svnlook | A tool for inspecting a Subversion repository. |
svnadmin | A tool for creating, tweaking or repairing a Subversion repository. |
svndumpfilter | A program for filtering Subversion repository dumpfile format streams. |
mod_dav_svn | A plug-in module for the Apache HTTP Server, used to make your repository available to others over a network. |
svnserve | A custom standalone server program, runnable as a daemon process or invokable by SSH; another way to make your repository available to others over a network. |
配置本地访问的SVN
执行svn --version,你将看到如下画面
[root@localhost local]# svn --version* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.* ra_local : Module for accessing a repository on local disk.* ra_svn : Module for accessing a repository using the svn network protocol.
如果你有ra_local这个模块,那么客户端就可以用file:// URLs的地址来访问。
执行一下命令
$ svnadmin create /root/svnrepo$ ls /root/svnrepoconf/ dav/ db/ format hooks/ locks/ README.txt
接下来,我们建立一个本地工作目录/root/svnlocal,进入执行
//建立项目[root@localhost svnlocal]# mkdir project [root@localhost svnlocal]# mkdir project/trunk[root@localhost svnlocal]# mkdir project/branches[root@localhost svnlocal]# mkdir project/tags//建立一个模块exo[root@localhost svnlocal]# mkdir project/exo[root@localhost svnlocal]# vi project/exo/exo.conf[root@localhost svnlocal]# svn import . file:///root/svnrepo -m 'initial'[root@localhost svnlocal]# rm -rf project[root@localhost svnlocal]# svn checkout file://localhost/root/svnrepo/project //check整个项目[root@localhost svnlocal]# svn checkout file://localhost/root/svnrepo/project exo //check 其中一个模块
如果成功可以看到文件已经被check出来。地址可以使用file://localhost/root/svnrepo 或者使用file:///root/svnrepo
其他的命令有
- Enter your working copy and edit a file's contents.
- Run svn diff to see unified diff output of your changes.
- Run svn commit to commit the new version of your file to the repository.
- Run svn update to bring your working copy “up-to-date” with the repository.
SVN的访问地址
Schema | Access Method |
---|
file:/// | direct repository access (on local disk) |
http:// | access via WebDAV protocol to Subversion-aware Apache server |
https:// | same as http://, but with SSL encryption. |
svn:// | access via custom protocol to an svnserve server |
svn+ssh:// | same as svn://, but through an SSH tunnel. |
启动SVN的svnserve,这样你就可以通过svn://url的方式来访问。
查看启动参数
[root@localhost svnlocal]# svnserve --helpUsage: svnserve [options]Valid options: -d [--daemon] : daemon mode --listen-port arg : listen port (for daemon mode) --listen-host arg : listen hostname or IP address (for daemon mode) --foreground : run in foreground (useful for debugging) -h [--help] : display this help --version : display version -i [--inetd] : inetd mode -r [--root] arg : root of directory to serve -R [--read-only] : deprecated; use repository config file -t [--tunnel] : tunnel mode --tunnel-user arg : tunnel username (default is current uid's name) -T [--threads] : use threads instead of fork -X [--listen-once] : listen once (useful for debugging)
我们执行svnserve -d -r /root/svnrepo
然后在刚才的svnlocal目录下,执行
[root@localhost svnlocal]# svn checkout svn://localhost/project exo
就可以通过网络协议check出指定的repo或者其中的模块
注意:如果我们启动时候,只是用svnserve -d而没有制定repo路径的话,那么你在checkout的时候就必须使用是svn checkout svn://localhost/root/svnrepo/project exo 来指明全路径。
接下来,我们随便修改一个文件,然后执行
[root@localhost exo-build]# svn commit -m "test"
你会发现提示说:“提交失败,svn: Connection is read-only” 这说明svn://访问方式没有用户权限控制,只能最基本的匿名下载使用。
权限配置
先介绍svnserve使用的基于文件的权限控制
进入/root/svnrepo/conf/ 打开svnserve.conf,修改一下两行
[general]anon-access = noneauth-access = write password-db = passwd
注意:所有的行都必须顶格,否则报错。
在相同目录下建立一个passwd文件,使用vi passwd命令。在里面输入
[users]danny = dannybobo = bobo
重新启动svnserve,svnserve -d -r /root/svnrepo/ 。
好,接下来,我们执行
[root@localhost svnlocal]# svn checkout svn://localhost/project exo
根据提示依次输入"root"的密码(任意),用户登陆名名(danny_xcz)和密码(pass)。就可以正常chekout需要的目录了。登陆一次以后再执行svn update等命令时无需再次输入认证密码。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=202474