您的位置:首页 > 其它

OSX本地搭建svn服务器

2014-12-01 10:25 239 查看
在OSX中搭建svn服务器管理代码简直再简单不过,因为OSX 原生支持svn:

首先我们应该创建一个代码仓库:

svnadmin create ~/svn/shumago


然后目录下会自动生成如下文件:

andy@AndyMacBookPro:~/svn/shumago$ ll
total 16
drwxr-xr-x   8 andy  staff  272 12  1 09:53 ./
drwxr-xr-x   4 andy  staff  136 12  1 09:53 ../
-rw-r--r--   1 andy  staff  229 12  1 09:53 README.txt
drwxr-xr-x   5 andy  staff  170 12  1 09:53 conf/
drwxr-sr-x  15 andy  staff  510 12  1 09:53 db/
-r--r--r--   1 andy  staff    2 12  1 09:53 format
drwxr-xr-x  11 andy  staff  374 12  1 09:53 hooks/
drwxr-xr-x   4 andy  staff  136 12  1 09:53 locks/
andy@AndyMacBookPro:~/svn/shumago$ cd conf/
andy@AndyMacBookPro:~/svn/shumago/conf$ ll
total 24
drwxr-xr-x  5 andy  staff   170 12  1 09:53 ./
drwxr-xr-x  8 andy  staff   272 12  1 09:53 ../
-rw-r--r--  1 andy  staff  1080 12  1 09:53 authz
-rw-r--r--  1 andy  staff   309 12  1 09:53 passwd
-rw-r--r--  1 andy  staff  3090 12  1 09:53 svnserve.conf
andy@AndyMacBookPro:~/svn/shumago/conf$


设置权限:

vim svnserve.conf :

[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz


vim passwd : 

[users]
andy = andy


vim authz : 

[/]
###andy = rw
*=

[shumago:/trunk]
andy = rw


以上所有配置每行要顶格写,否则会报错。

*= 的意思是所有用户都禁用。

创建工程结构:

release

trunk

branch

的方法很简单:

我们到我们创建的一个目录,例如:

/usr/local/webdata/shumago/

下,然后创建三个目录如下:

andy@AndyMacBookPro:/usr/local/webdata/shumago$ ll
total 0
drwxr-xr-x   6 andy  admin   204 12  1 15:29 ./
drwxr-xr-x  49 andy  admin  1666 12  1 15:06 ../
drwxr-xr-x   7 andy  admin   238 12  1 15:35 .svn/
drwxr-xr-x   2 andy  admin    68 12  1 15:07 branch/
drwxr-xr-x   2 andy  admin    68 12  1 15:07 release/
drwxr-xr-x  13 andy  admin   442 12  1 15:35 trunk/
andy@AndyMacBookPro:/usr/local/webdata/shumago$


然后我们选择add文件夹到工程:

svn add *

然后再:

svn commit

就可以了。

之后我们需要将我们的文件导入到trunk中去:

andy@AndyMacBookPro:~/svn/shumago$ svn import /usr/local/webdata/shumagobak svn://localhost/shumago/trunk -m 'init trunk'


就对trunk目录进行了初始化。

然后我们需要从trunk创建一个branch的时候,这样来:

andy@AndyMacBookPro:/usr/local/webdata/shop72hour$ svn cp svn://localhost/shop72hour/trunk svn://localhost/shop72hour/branch/story2 -m 'story#2::首页商品静态化'

Committed revision 15.
andy@AndyMacBookPro:/usr/local/webdata/shop72hour$


关于svn服务器:

启动svn服务

sudo svnserve -d -r ~/svn &

关掉服务:

sudo killall svnserve

一些问题:

1.

在搭建好svn服务器之后,我发现提交(commit)的一些更改的日志没有,我通过寻找网上的一些方法,试着把svnserve.conf

anon-access = read

修改为:

anon-access = none

这一项代表的意思大概是匿名方式访问时的权限,我们连read的权限也不给他,当匿名时你什么也做不了,后来log日志就有了。

andy@AndyMacBookPro:~/svn/shumago$ svn log svn://localhost/shumago
------------------------------------------------------------------------
r8 | andy | 2014-12-01 21:12:16 +0800 (一, 01 12 2014) | 1 line

修改分类页面网站title
------------------------------------------------------------------------
r7 | andy | 2014-12-01 18:35:16 +0800 (一, 01 12 2014) | 1 line

去掉今天昨天前天,修改为显示全部宝贝
------------------------------------------------------------------------
r6 | andy | 2014-12-01 16:08:00 +0800 (一, 01 12 2014) | 1 line

story##1::首页修改为显示全部商品
------------------------------------------------------------------------
r5 | andy | 2014-12-01 16:03:25 +0800 (一, 01 12 2014) | 1 line

init release
------------------------------------------------------------------------
r4 | andy | 2014-12-01 16:02:29 +0800 (一, 01 12 2014) | 1 line

del
------------------------------------------------------------------------
r3 | andy | 2014-12-01 15:59:11 +0800 (一, 01 12 2014) | 1 line

init release
------------------------------------------------------------------------
r2 | andy | 2014-12-01 15:35:21 +0800 (一, 01 12 2014) | 1 line

init trunk
------------------------------------------------------------------------
r1 | andy | 2014-12-01 15:32:58 +0800 (一, 01 12 2014) | 1 line

添加工程目录
------------------------------------------------------------------------
andy@AndyMacBookPro:~/svn/shumago$


2. 将branch分支上的更改合并到trunk上,这里是将story1上的版本6-13合并到trunk上,这里没有指定版本,所有是将story1上的所有版本合并到trunk上:

andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn sw svn://localhost/shop72hour/trunk .
D    baidu_verify_pe2uaGLtBm.html
U    model/index.model.php
U    controller/index.class.php
U    static/css/wookmark/style.css
U    core/init.php
U    view/time_nav.html
U    view/index/cat.html
U    view/index/index.html
U    index.php
Updated to revision 13.
andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn info
Path: .
Working Copy Root Path: /usr/local/webdata/shop72hour2
URL: svn://localhost/shop72hour/trunk
Repository Root: svn://localhost/shop72hour
Repository UUID: ae5aaff5-ae9f-44da-813d-e1e877dadde8
Revision: 13
Node Kind: directory
Schedule: normal
Last Changed Author: andy
Last Changed Rev: 2
Last Changed Date: 2014-12-01 15:35:21 +0800 (一, 01 12 2014)

andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn status
andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn merge svn://localhost/shop72hour/branch/story1
--- Merging r6 through r13 into '.':
U    model/index.model.php
U    controller/index.class.php
U    static/css/wookmark/style.css
U    core/init.php
U    view/time_nav.html
U    view/index/cat.html
U    view/index/index.html
A    baidu_verify_pe2uaGLtBm.html
U    index.php
--- Recording mergeinfo for merge of r6 through r13 into '.':
U   .
andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$


如果想指定版本号来merge,也可以用以下方式:

svn -r 148:149 merge svn://server/trunk branches/ep 其中148和149是两次修改的版本号。

如果这个时候我们去查看 . 目录,会发现如下状态:

andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn info
Path: .
Working Copy Root Path: /usr/local/webdata/shop72hour2
URL: svn://localhost/shop72hour/trunk
Repository Root: svn://localhost/shop72hour
Repository UUID: ae5aaff5-ae9f-44da-813d-e1e877dadde8
Revision: 13
Node Kind: directory
Schedule: normal
Last Changed Author: andy
Last Changed Rev: 2
Last Changed Date: 2014-12-01 15:35:21 +0800 (一, 01 12 2014)

andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$ svn status
M      .
A  +    baidu_verify_pe2uaGLtBm.html
M       controller/index.class.php
M       core/init.php
M       index.php
M       model/index.model.php
M       static/css/wookmark/style.css
M       view/index/cat.html
M       view/index/index.html
M       view/time_nav.html
andy@AndyMacBookPro:/usr/local/webdata/shop72hour2$


说明merge以后我们还需要将变更commit到trunk上去才行,所以下面我们需要commit:

提交之后,trunk本地版本+1变为14,如下:

andy@AndyMacBookPro:/usr/local/webdata/shop72hourtrunk$ svn info
Path: .
Working Copy Root Path: /usr/local/webdata/shop72hourtrunk
URL: svn://localhost/shop72hour/trunk
Repository Root: svn://localhost/shop72hour
Repository UUID: ae5aaff5-ae9f-44da-813d-e1e877dadde8
Revision: 14
Node Kind: directory
Schedule: normal
Last Changed Author: andy
Last Changed Rev: 14
Last Changed Date: 2014-12-02 14:31:47 +0800 (二, 02 12 2014)

andy@AndyMacBookPro:/usr/local/webdata/shop72hourtrunk$
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: