svn - TuPengXiong/TuPengXiong.github.io GitHub Wiki

svn 官网

ubuntu 搭建svnserver

apt-get install subversion

新建文件夹作为svn的目录

mkdir /data0/svn

新建资源仓库

svnadmin create /data0/svn/repo

目录用途说明

ll /data0/svn/repo
conf db format hooks locks README.txt  
  • hooks目录:放置hook脚本文件的目录
  • locks目录:用来放置subversion的db锁文件和db_logs锁文件的目录,用来追踪存取文件库的客户端
  • format文件:是一个文本文件,里面只放了一个整数,表示当前文件库配置的版本号
  • conf目录:是这个仓库的配置文件(仓库的用户访问账号、权限等)

conf 权限相关设置

  • vim /data0/svn/repo/conf/svnserver.conf
[general]   
anon-access = none    # 不可匿名访问
auth-access = write   # 认证可读写
password-db = /data0/svn/repo/conf/passwd   #用户名和密码
authz-db = /data0/svn/repo/conf/authz   # 权限配置
#realm = My Test Repository #这是个提示信息  
  • vim /data0/svn/repo/conf/passwd
    [users]
    test = 123456
    test1 = 123456
    test2 = 123456

  • vim /data0/svn/repo/conf/authz

[groups]
# 用户分组 
admin = test,test1
user = test2   
[/]   
# 给相应的权限   
@admin = rw   #读写
@user = r     #可读
* =  

启动服务


svnserve -d -r /data0/svn/ \  
--listen-port 3690 \
--listen-host 0.0.0.0 \
--log-file /data0/svn/repo/svn.log \
--pid-file /data0/svn/repo/svn.pid

注意 :-d -r /data0/svn/ 只需要到根目录,不需要到仓库目录

访问测试

svn co svn://127.0.0.1/repo auth
接下来根据提示 输入用户名和密码就OK了
ps:repo 是仓库名字

svn co svn://127.0.0.1/repo auth

Authentication realm: <svn://127.0.0.1:3690> 276ac2e0-90f5-497e-b321-8b49695c8d28
Password for 'root': ***********

Authentication realm: <svn://127.0.0.1:3690> 276ac2e0-90f5-497e-b321-8b49695c8d28
Username: test 
Password for 'test ': **************


-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://127.0.0.1:3690> 276ac2e0-90f5-497e-b321-8b49695c8d28

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes

svnadmin --help

general usage: svnadmin SUBCOMMAND REPOS_PATH  [ARGS & OPTIONS ...]
Subversion repository administration tool.
Type 'svnadmin help <subcommand>' for help on a specific subcommand.
Type 'svnadmin --version' to see the program version and FS modules.

Available subcommands:
   crashtest
   create
   delrevprop
   deltify
   dump
   freeze
   help (?, h)
   hotcopy
   info
   list-dblogs
   list-unused-dblogs
   load
   lock
   lslocks
   lstxns
   pack
   recover
   rmlocks
   rmtxns
   setlog
   setrevprop
   setuuid
   unlock
   upgrade
   verify

svnserve --help

usage: svnserve [-d | -i | -t | -X] [options]
Subversion repository server.
Type 'svnserve --version' to see the program version.

Valid options:
  -d [--daemon]            : daemon mode
  -i [--inetd]             : inetd mode
  -t [--tunnel]            : tunnel mode
  -X [--listen-once]       : listen-once mode (useful for debugging)
  -r [--root] ARG          : root of directory to serve
  -R [--read-only]         : force read only, overriding repository config file
  --config-file ARG        : read configuration from file ARG
  --listen-port ARG        : listen port. The default port is 3690.
                             [mode: daemon, listen-once]
  --listen-host ARG        : listen hostname or IP address
                             By default svnserve listens on all addresses.
                             [mode: daemon, listen-once]
  -6 [--prefer-ipv6]       : prefer IPv6 when resolving the listen hostname
                             [IPv4 is preferred by default. Using IPv4 and IPv6
                             at the same time is not supported in daemon mode.
                             Use inetd mode or tunnel mode if you need this.]
  -c [--compression] ARG   : compression level to use for network transmissions
                             [0 .. no compression, 5 .. default, 
                              9 .. maximum compression]
  -M [--memory-cache-size] ARG : size of the extra in-memory cache in MB used to
                             minimize redundant operations.
                             Default is 16.
                             0 switches to dynamically sized caches.
                             [used for FSFS and FSX repositories only]
  --cache-txdeltas ARG     : enable or disable caching of deltas between older
                             revisions.
                             Default is yes.
                             [used for FSFS and FSX repositories only]
  --cache-fulltexts ARG    : enable or disable caching of file contents
                             Default is yes.
                             [used for FSFS and FSX repositories only]
  --cache-revprops ARG     : enable or disable caching of revision properties.
                             Consult the documentation before activating this.
                             Default is no.
                             [used for FSFS and FSX repositories only]
  --client-speed ARG       : Optimize network handling based on the assumption
                             that most clients are connected with a bitrate of
                             ARG Mbit/s.
                             Default is 0 (optimizations disabled).
  --block-read ARG         : Parse and cache all data found in block instead
                             of just the requested item.
                             Default is no.
                             [used for FSFS repositories in 1.9 format only]
  -T [--threads]           : use threads instead of fork [mode: daemon]
  --min-threads ARG        : Minimum number of server threads, even if idle.
                             Capped to max-threads; minimum value is 0.
                             Default is 1.
                             [used only with --threads]
  --max-threads ARG        : Maximum number of server threads, even if there
                             are more connections.  Minimum value is 1.
                             Default is 256.
                             [used only with --threads]
  --foreground             : run in foreground (useful for debugging)
                             [mode: daemon]
  --single-thread          : handle one connection at a time in the parent
                             process (useful for debugging)
  --log-file ARG           : svnserve log file
  --pid-file ARG           : write server process ID to file ARG
                             [mode: daemon, listen-once]
  --tunnel-user ARG        : tunnel username (default is current uid's name)
                             [mode: tunnel]
  -h [--help]              : display this help
  --virtual-host           : virtual host mode (look for repo in directory
                             of provided hostname)
  --version                : show program version information
  -q [--quiet]             : no progress (only errors) to stderr

svn --help

 svn --help
usage: svn <subcommand> [options] [args]
Subversion command-line client.
Type 'svn help <subcommand>' for help on a specific subcommand.
Type 'svn --version' to see the program version and RA modules
  or 'svn --version --quiet' to see just the version number.

Most subcommands take file and/or directory arguments, recursing
on the directories.  If no arguments are supplied to such a
command, it recurses on the current directory (inclusive) by default.

Available subcommands:
   add
   auth
   blame (praise, annotate, ann)
   cat
   changelist (cl)
   checkout (co)
   cleanup
   commit (ci)
   copy (cp)
   delete (del, remove, rm)
   diff (di)
   export
   help (?, h)
   import
   info
   list (ls)
   lock
   log
   merge
   mergeinfo
   mkdir
   move (mv, rename, ren)
   patch
   propdel (pdel, pd)
   propedit (pedit, pe)
   propget (pget, pg)
   proplist (plist, pl)
   propset (pset, ps)
   relocate
   resolve
   resolved
   revert
   status (stat, st)
   switch (sw)
   unlock
   update (up)
   upgrade

⚠️ **GitHub.com Fallback** ⚠️