首页 > 代码库 > svn的简单使用

svn的简单使用

1.建立svn库

syswjdeMacBook-Air:~ syswj$ mkdir svn
syswjdeMacBook-Air:~ syswj$ ls
Desktop   Downloads Movies    Pictures  solarized
Documents Library   Music     Public    svn
syswjdeMacBook-Air:~ syswj$ svnadmin create /Users/syswj/svn/resp1
syswjdeMacBook-Air:~ syswj$ cd ./svn/
syswjdeMacBook-Air:svn syswj$ ls
resp1
syswjdeMacBook-Air:svn syswj$ cd ./resp1/
syswjdeMacBook-Air:resp1 syswj$ ls
README.txt conf       db         format     hooks      locks
syswjdeMacBook-Air:resp1 syswj$
2.设置用户名,密码,权限

syswjdeMacBook-Air:resp1 syswj$ cd ./conf/
syswjdeMacBook-Air:conf syswj$
 16 ### The sample settings below are the defaults and specify that anonymous
syswjdeMacBook-Air:conf syswj$ ls
authz         passwd        svnserve.conf
syswjdeMacBook-Air:conf syswj$ vim
syswjdeMacBook-Air:conf syswj$
svnserve.config:  去掉[general]中的 anon-access = read      auth-access = write     password-db = passed     authz-db = authz 去掉前面的#和空格

password:去掉[user]中用户的#和空格,可以字节添加用户名和密码

authz :去掉[group]中的harry_and_sally前的#和空格,添加[/]赋予所以权限,把harry。。用户组加进去

[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

[/]
@harry_and_sally = rw
3.开启svn服务

syswjdeMacBook-Air:~ syswj$ svnserve -d -r /Users/syswj/svn/
svnserve: E000048: Can't bind server socket: Address already in use
syswjdeMacBook-Air:~ syswj$ svnserve -d -r /Users/syswj/svn/
syswjdeMacBook-Air:~ syswj$
开启过的化进入"活动监视器"关闭掉(在launchpad中)

4.svn import导入文件到resp1库中

Adding         Documents/common/lib_3rd/openssl-1.0.1h/util/do_ms.sh
Adding         Documents/common/lib_3rd/openssl-1.0.1h/util/files.pl

Committed revision 1.
syswjdeMacBook-Air:~ syswj$ svn import /Users/syswj/Documents/common/ svn://localhost/resp1/ --username=harry --password=harryssecret -m "chushihua"

5.svn checkout 

新建一个目录,作为类似于客户端

syswjdeMacBook-Air:svn_client syswj$ svn co svn://localhost/resp1 --username=harry --password=harryssecret ./
estored 'lib_3rd/openssl-1.0.1h/util/files.pl'
Checked out revision 1.
syswjdeMacBook-Air:svn_client syswj$ ls
include          lib              lib_3rd          sftp-config.json src
syswjdeMacBook-Air:svn_client syswj$
syswjdeMacBook-Air:svn_client syswj$ ls
include          lib              lib_3rd          sftp-config.json src
syswjdeMacBook-Air:svn_client syswj$ pwd
/Users/syswj/svn_client
syswjdeMacBook-Air:svn_client syswj$

6.基本命令:

svn commit   文件名字/目录    -m "标记"

syswjdeMacBook-Air:svn_client syswj$ svn ci sftp-config.json -m "re"
Sending        sftp-config.json
Transmitting file data .
Committed revision 2.
syswjdeMacBook-Air:svn_client syswj$ svn info
Path: .
Working Copy Root Path: /Users/syswj/svn_client
URL: svn://localhost/resp1
Repository Root: svn://localhost/resp1
Repository UUID: 03d7e179-7ddc-41a3-bb6e-5e37cbe3d9d4
Revision: 1
Node Kind: directory
Schedule: normal
Last Changed Author: harry
Last Changed Rev: 1
Last Changed Date: 2014-10-22 20:58:09 +0800 (三, 22 10 2014)

syswjdeMacBook-Air:svn_client syswj$ svn st
syswjdeMacBook-Air:svn_client syswj$
svn delete  文件名字/目录   -m "标记"

syswjdeMacBook-Air:svn_client syswj$ ls
include          lib              lib_3rd          sftp-config.json src
syswjdeMacBook-Air:svn_client syswj$ svn delete lib
D         lib
syswjdeMacBook-Air:svn_client syswj$ svn ci -m "delete"
Deleting       lib

Committed revision 3.
syswjdeMacBook-Air:svn_client syswj$ ls
include          lib_3rd          sftp-config.json src
syswjdeMacBook-Air:svn_client syswj$

svn update  目录名/文件名    将目录或者文件更新到最新版本

 参考:http://blog.csdn.net/q199109106q/article/details/8655204 



svn的简单使用