ubuntu SVN随记

来源:互联网 发布:mac解压rar免费 编辑:程序博客网 时间:2024/06/05 10:19

 

安装SVN

$ sudo apt-get install subversion
$ sudo apt-get install libapache2-svn


创建SVN仓库
sudo addgroup subversion
sudo usermod -G subversion -a www-data

sudo mkdir /home/svn
fenglifeng@feng:/home$ cd /home/svn
fenglifeng@feng:/home/svn$ sudo mkdir myproject
fenglifeng@feng:/home/svn$ sudo chown -R root:subversion myproject
fenglifeng@feng:/home/svn$ sudo svnadmin create /home/svn/myproject
fenglifeng@feng:/home/svn$ sudo chmod -R g+rws myproject


导入项目
sudo svn import app_v3.1.0_r3534/ file:///home/svn/myproject/code/trunk/app_v3.1.0_r3534 -m "v3.1.0 opulan"

导出至本地
svn co file:///home/svn/myproject/code/trunk/app_v3.1.0_r3534

增加文件:fenglifeng@feng: sudo svn add test.c
fenglifeng@feng:~/code/shm/myproject/shm/posix$ sudo svn ci -m "add test.c"

删除文件:
svn delete test.c -m "delete test.c"

更新
fenglifeng@feng:~/code/shm/myproject/shm/posix$ svn update -r 1   //1是版本号
如果在提交的时候提示过期的话,是因为冲突,需要先update,修改文 件,然后清除svn resolved,最后再提交commit

比较:
svn diff -r 1:2   //1  2 是版本号


将两个版本之间的差异合并到当前文件

svn merge -r m:n path
例如:svn merge -r 200:205 test.php(将版本200与205之间的差异合并到当前文件,但是一般都会产生冲突,需要处理一下)


apache:
要通过 WebDAV 协议访问 SVN 文件仓库,您必须配置您的 Apache 2 Web 服务器。您必须加入下面的代码片段到您的 /etc/apache2/mods-available/dav_svn.conf中:

<Location /svn/myproject>
DAV svn
SVNPath /home/svn/myproject
AuthType Basic
AuthName "myproject subversion repository"
AuthUserFile /etc/subversion/passwd
#<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
#</LimitExcept>
</Location>

当您添加了上面的内容,您必须重新起动 Apache 2 Web 服务器,请输入下面的命令:
sudo /etc/init.d/apache2 restart

接下来,您需要创建 /etc/subversion/passwd 文件,该文件包含了用户授权的详细信息。要添加用户,您可以执行下面的命令:

sudo htpasswd -c /etc/subversion/passwd user_name //创建AuthUserFile /etc/subversion/passwd
它会提示您输入密码,当您输入了密码,该用户就建立了。“-c”选项表示创建新的/etc/subversion/passwd文件,所以user_name所指的用户将是文件中唯一的用户。如果要添加其他用户,则去掉“-c”选项即可:

sudo htpasswd /etc/subversion/passwd other_user_name


您可以通过下面的命令来访问文件仓库:
 svn co http://localhost/svn/myproject/code/trunk/app_v3.1.0_r3534/ //导出文件


可以再web页面上输入地址:http://localhost/svn/myproject/code/trunk/app_v3.1.0_r3534/  浏览文件


也可以通过svn自带的协议来实现远程SVN服务(在redhat上实验的)

配置在仓库中myproject的conf文件。

for:

passwd 
### 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
fenglifeng=123456


authz 
### 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, to a group of users defined in a special [groups]
### section, or to anyone using the '*' wildcard.  Each definition can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').


[groups]
# harry_and_sally = harry,sally
[/]
harry = rw
fenglifeng = rw
# [/foo/bar]
# harry = rw
# * =


# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r


svnserve.conf 
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)


### Visit http://subversion.tigris.org/ for more information.


[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = none
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 conf directory.
### 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 conf
### directory.  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



启动svn服务器

$:svnserve -d -r /home/svn/

导入代码:

svn import ONU_APP_CODE/  svn://192.168.2.104/app/code -m "8M without fs"  --username fenglifeng


跨平台使用的话,svn的url即为:svn://192.168.2.104/app/code 

svn co https://192.168.2.35:8443/svn/ONU_APP_CODE

原创粉丝点击