在Mac上建立SVN服务器
2014-03-25 23:42
183 查看
其实我一直都在用Cornerstone来管理代码,也挺好用的,我之所以写这篇文章是因为Mac本身支持建立SVN,也算是练习一下,仅能满足基本的需求。(本文参考http://www.cnblogs.com/mjios/archive/2013/03/10/2952258.html)
总的来说分下面几个步骤:
一、建立代码仓库
为了表达的方便,我就建立在桌面上,首先,在桌面上建立一个名为SVN的文件夹
打开终端创建一个保存某个项目的文件夹,名为SQLDemo(这个文件夹下保存的是操作数据库的工程),输入指令:
svnadmin create /Users/liuning/Desktop/SVN/SQLDemo,执行后,会在SQLDemo文件加载多出一个目录结构,如下:
二、配置SVN用户权限
主要是修改SQLDemo/conf文件夹下的三个文件
打开svnserve.conf,把下面配置前的#和空格去掉(使用文本编辑器打开即可)
[general]
### 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
### 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
### 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
其中,anon-access = read
代表匿名访问时是只读的
打开passwd,在[users]线面添加账号和密码
[users]
zhangsan=123
lisi=lisi
上面表示第一个账号是zhangsan密码是123,第二个账号是lisi密码是lisi
打开authz配置用户组合权限
可以讲在Passwd里面添加的用户分到不同的用户组里,可以对不同的组设置不同的权限,这样就省去了对每个用户单独设置权限
在[groups]下面添加组名和用户名,多个用户之间用逗号隔开,接下来进行权限配置,使用[/]代表svn服务器上的所有资源库,如下图
三、启动服务器
在终端输入下列指令,svnserve -d -r /Users/liuning/Desktop/SVN,如果没有任何反应说明启动成功了。如下:
当然,如果你要退出服务器,可以从“活动监视器”里退出这个进程
目前为止,svn服务器的搭建已经完成了,下面从本地导入代码到服务器
在终端输入
svn import /Users/liuning/Desktop/SQLiteDemo svn://localhost/SQLDemo --username=zhangsan --password=123 -m "first input"
再输入你设置的用户的用户名和密码,就会出现代码上传的状态.
四、从服务器下载代码到本地
在终端输入
localhost:~ liuning$ svn checkout svn://localhost/SQLDemo --username=zhangsan --password=123 /Users/liuning/Desktop/checkFrmoSVN
这样桌面上会创建一个checkFromSVN的文件夹,里面就是你下载的那个程序
五、提交更新过的代码到svn服务器
打开终端进入到checkFromSVN文件夹
localhost:~ liuning$ cd /Users/liuning/Desktop/checkFrmoSVN
输入提交命令:
localhost:checkFrmoSVN liuning$ svn commit -m
六、更新svn上的代码到客户端
首先还是进入到checkFromSVN文件夹,输入下列命令:
localhost:checkFrmoSVN liuning$ svn update
至此,完成了svn上代码同步的基本操作,如果要使用svn的其他用法,在终端输入svn help
总的来说分下面几个步骤:
一、建立代码仓库
为了表达的方便,我就建立在桌面上,首先,在桌面上建立一个名为SVN的文件夹
打开终端创建一个保存某个项目的文件夹,名为SQLDemo(这个文件夹下保存的是操作数据库的工程),输入指令:
svnadmin create /Users/liuning/Desktop/SVN/SQLDemo,执行后,会在SQLDemo文件加载多出一个目录结构,如下:
二、配置SVN用户权限
主要是修改SQLDemo/conf文件夹下的三个文件
打开svnserve.conf,把下面配置前的#和空格去掉(使用文本编辑器打开即可)
[general]
### 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
### 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
### 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
其中,anon-access = read
代表匿名访问时是只读的
打开passwd,在[users]线面添加账号和密码
[users]
zhangsan=123
lisi=lisi
上面表示第一个账号是zhangsan密码是123,第二个账号是lisi密码是lisi
打开authz配置用户组合权限
可以讲在Passwd里面添加的用户分到不同的用户组里,可以对不同的组设置不同的权限,这样就省去了对每个用户单独设置权限
在[groups]下面添加组名和用户名,多个用户之间用逗号隔开,接下来进行权限配置,使用[/]代表svn服务器上的所有资源库,如下图
三、启动服务器
在终端输入下列指令,svnserve -d -r /Users/liuning/Desktop/SVN,如果没有任何反应说明启动成功了。如下:
当然,如果你要退出服务器,可以从“活动监视器”里退出这个进程
目前为止,svn服务器的搭建已经完成了,下面从本地导入代码到服务器
在终端输入
svn import /Users/liuning/Desktop/SQLiteDemo svn://localhost/SQLDemo --username=zhangsan --password=123 -m "first input"
再输入你设置的用户的用户名和密码,就会出现代码上传的状态.
四、从服务器下载代码到本地
在终端输入
localhost:~ liuning$ svn checkout svn://localhost/SQLDemo --username=zhangsan --password=123 /Users/liuning/Desktop/checkFrmoSVN
这样桌面上会创建一个checkFromSVN的文件夹,里面就是你下载的那个程序
五、提交更新过的代码到svn服务器
打开终端进入到checkFromSVN文件夹
localhost:~ liuning$ cd /Users/liuning/Desktop/checkFrmoSVN
输入提交命令:
localhost:checkFrmoSVN liuning$ svn commit -m
六、更新svn上的代码到客户端
首先还是进入到checkFromSVN文件夹,输入下列命令:
localhost:checkFrmoSVN liuning$ svn update
至此,完成了svn上代码同步的基本操作,如果要使用svn的其他用法,在终端输入svn help
相关文章推荐
- MAC下的SVN服务器建立
- [系统教程] MAC下的SVN服务器建立
- Mac中建立SVN服务器
- MAC下的SVN服务器建立
- MAC下的SVN服务器建立
- MAC下的SVN服务器建立
- MAC下的SVN服务器建立
- MAC下的SVN服务器建立
- MAC下使用终端和Xcode 7进行SVN服务器建立与使用
- Mac下配置svn服务器
- Mac下搭建svn服务器和XCode配置svn
- Mac OS X上搭建本地SVN服务器
- mac下配置svn服务器详解及用户的权限管理(亲测)
- mac下配置svn服务器
- SVN服务器的建立过程中几个问题
- linux 搭建SVN服务器,为多个项目分别建立版本库并单独配置权限
- windows 建立SVN服务器
- Mac下配置SVN服务器及连接本地服务器
- Mac搭建本地svn服务器,并用Cornerstone连接服务器
- Mac OS X Snow Leopard 开启Web共享,建立Web服务器:Apache+PHP+MySql