svn常用命令

1、新建版本库

[root@localhost repos]# mkdir -p project
[root@localhost repos]# svnadmin create project
[root@localhost repos]# cd project/
[root@localhost project]# ll
total 24
drwxr-xr-x. 2 root root 4096 Oct 26 20:56 conf
drwxr-sr-x. 6 root root 4096 Oct 26 20:56 db
-r--r--r--. 1 root root 2 Oct 26 20:56 format
drwxr-xr-x. 2 root root 4096 Oct 26 20:56 hooks
drwxr-xr-x. 2 root root 4096 Oct 26 20:56 locks
-rw-r--r--. 1 root root 246 Oct 26 20:56 README.txt

2、修改版本配置文件

[root@localhost project]# vim conf/svnserve.conf
[general]
anon-access = none #必须设置为none,否则用户不用输入密码就可以访问
auth-access = write
password-db = passwd
authz-db = authz

设置用户账号

[root@localhost project]# vim conf/passwd
[users]
test001 =
test002 =

设置用户访问权限

[root@localhost project]# vim conf/authz
[groups]
team1 = test001,test002 [/]
@team1 = rw
* = r

3、创建目录

[root@localhost project]# svn mkdir svn://192.168.232.129/project/trunk -m 'mkdir'
Authentication realm: <svn://192.168.x.x:3690> 47b5742a-9bf9-11e6-8afb-e34d594fc31e
Password for 'root': ****** Authentication realm: <svn://192.168.x.x:3690> 47b5742a-9bf9-11e6-8afb-e34d594fc31e
Username: test001
Password for 'test001': ******
......
Committing transaction...
Committed revision .
[root@localhost project]# svn mkdir svn://192.168.232.129/project/branches -m 'mkdir'
[root@localhost project]# svn mkdir svn://192.168.232.129/project/tags -m 'mkdir'

4、导入项目

[root@localhost project]# svn import /var/www/web/gettext/  svn://192.168.x.x/project/trunk/ -m 'init project'
Authentication realm: <svn://192.168.x.x:3690> 47b5742a-9bf9-11e6-8afb-e34d594fc31e
Password for 'test001': ******
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no
Adding /var/www/web/gettext/hello.php
Adding /var/www/web/gettext/index.php
Committing transaction...
Committed revision .

5、检出项目、添加、提交代码

[root@localhost web]# svn checkout svn://192.168.x.x/project
A project/branches
A project/tags
A project/trunk
A project/trunk/hello.php
A project/trunk/index.php
Checked out revision .
[root@localhost project]# svn status
? test.php
[root@localhost project]# svn add test.php
A test.php
[root@localhost project]#svn commit -m 'add test.php'

6、新建分支

[root@localhost project]# svn copy svn://192.168.x.x/project/trunk/ svn://192.168.x.x/project/branches/v-1.0 -m 'add branch'
上一篇:svn 常用命令总结


下一篇:我所记录的git命令(非常实用)