SVN安装 | 菜鸟教程
一、搭建SVN服务器
1、安装SVN
yum install subversion
检查是否安装成功
svn --version
[root@VM-0-4-centos ~]# svn --version
svn, version 1.7.14 (r1542130)
compiled Sep 30 2020, 17:44:04
Copyright (C) 2013 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
* handles 'http' scheme
* handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
* with Cyrus SASL authentication
* handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
* handles 'file' scheme
*
2、SVN 启动模式
2.1 手动新建版本库目录
mkdir /opt/svn
2.2 利用svn命令创建版本库
svnadmin create /opt/svn/project
[root@VM-0-4-centos project]# ll /opt/svn/project/
total 24
drwxr-xr-x 2 root root 4096 Aug 3 00:49 conf
drwxr-sr-x 6 root root 4096 Aug 3 00:24 db
-r--r--r-- 1 root root 2 Aug 3 00:24 format
drwxr-xr-x 2 root root 4096 Aug 3 00:24 hooks
drwxr-xr-x 2 root root 4096 Aug 3 00:24 locks
-rw-r--r-- 1 root root 229 Aug 3 00:24 README.txt
增加 trunk(主分支)、branches、tags分支
2.3 修改配置文件
进入/opt/svn/project/conf目录
cd /opt/svn/project/conf
2.3.1 修改authz
vi authz
在末尾添加
[/]
zhuang = rw
- 给用户zhuang赋予写和读的权限
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### - a single user,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[/]
zhuang = rw
2.3.2 修改passwd
vi passwd
在末尾添加
zhuang = zhuang123
- 添加用户zhuang,密码zhuang123
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
zhuang = zhuang123
2.3.3 修改svnserve.conf
vi svnserve.conf
## The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = read #给匿名用户给与读的权限
auth-access = write #给授权用户拥有读写的权限
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd #指定用户名的口令文件 相对路径:conf目录下
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz #指定权限配置文件 相对路径:conf目录下
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
# realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above. Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none
2.4 使用命令svnserve启动服务
svnserve -d -r 目录 --listen-port 端口号
- -r: 配置方式决定了版本库访问方式。
- -d: 后台启动。
- –listen-port: 指定SVN监听端口,不加此参数,SVN默认监听3690
执行命令启动服务
svnserve -d -r /opt/svn
3、SVN检出操作
svn checkout svn://1.13.152.218/project
检出路径Mac目录:/Users/mrzhuang/Downloads
192:Downloads mrzhuang$ svn checkout svn://1.13.152.218/project
认证领域: <svn://1.13.152.218:3690> f058151d-c5fa-4e5b-b683-b654656e1fb0
“mrzhuang”的密码: **********
认证领域: <svn://1.13.152.218:3690> f058151d-c5fa-4e5b-b683-b654656e1fb0
用户名: zhuang
“zhuang”的密码: *********
取出版本 0。
4、Mac使用Cornerstone连接SVN服务器
4.1 左侧栏右击选择 Add Repository
4.2 点击SVN Server,填入server、port、path、Name与Password,点击 Add
成功连接:
4.3 创建分支
我们可以看出project版本仓库是没有分支的,需要我们自己创建:
选中project版本仓库,在右侧右击选择 New Folder in “project”
创建 trunk(主分支)、branches与tags分支