把linux作为客户端管理svn版本库,不一定是svn服务器。
1.svn管理命令用法:[root@xiaoyu ~]# svn --help
usage: svn [opations] [args]
Subversion command-line client, version 1.7.14.
Type 'svn help ' 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
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) ==>将从svn server端文件同步到本地
upgrade
Subversion is a tool for version control.
For additional information, see http://subversion.apache.org/
[root@xiaoyu ~]#
2.从SVN库提取数据:(1)将文件checkout到本地目录:
svn checkout(co) remotepath localpath
例如:
[root@xiaoyu ~]# svn co svn://192.168.1.10/project /svn/ --username=xiaoyu --password=123456 ==>等价于svn co svn://192.168.1.10/project /svn/ --username=xiaoyu --password=123456
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
513c765e-d03b-4eaf-bede-c8deb7c56a29
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
A /svn/SVN Windows客户端保存密码的位置.txt
A /svn/xioyu.txt
Checked out revision 4.
[root@xiaoyu ~]# ll /svn/
total 4
-rw-r--r--. 1 root root 25 Sep 21 10:44 SVN Windows客户端保存密码的位置.txt
-rw-r--r--. 1 root root 0 Sep 21 10:44 xioyu.txt
提示:如果报错:svn Can't convert string from 'UTF-8' to native encoding:
原因:字符集问题
解决方法:注意调整CRT字符集
epport LC_CTYPE="en_US.UTF-8"
export LC_ALL=
或通过LANG解决
3.查看svn中的数据[root@xiaoyu ~]# svn list svn://192.168.1.10/project ==>等价于svn ls svn://192.168.1.10/project
SVN Windows客户端保存密码的位置.txt
syt.txt
xioyu.txt
[root@xiaoyu ~]# svn list svn://192.168.1.10/project --username=xiaoyu --password=123456 ==>等价于svn ls svn://192.168.1.10/project --username=xiaoyu --password=123456
SVN Windows客户端保存密码的位置.txt
syt.txt
xioyu.txt
[root@xiaoyu ~]# svn list svn://192.168.1.10/project --username=xiaoyu --password=123456 --verbose
5 xiaoyu Sep 21 10:47 ./
2 xiaoyu 25 Sep 20 15:38 SVN Windows客户端保存密码的位置.txt
5 xiaoyu 0 Sep 21 10:47 syt.txt
3 xiaoyu 0 Sep 20 15:46 xioyu.txt
[root@xiaoyu ~]# svn cat svn://192.168.1.10/project/xiaoyu.txt ==>查看文件中的内容
svn
4.从linux客户端本地提交数据到svn[root@xiaoyu svn]# svn add a b c d e f
A a
A b
A c
A d
A e
A f
[root@xiaoyu svn]# svn ci -m "svn data commit"
Adding a
Adding b
Adding c
Adding d
Adding e
Adding f
Transmitting file data ......
Committed revision 8.
提示:
==>-m "svn data commit" 必须接-m参数,-m参数后面的内容自定义,否则不能提交
通过windows客户端查看svn服务器上是否有上述提交的数据:
5.svn import:[root@xiaoyu ~]# mkdir -p /svn/trunk /svn/branch /svn/tag ==>trunk:主干 branch:分支 tag:标记
[root@xiaoyu ~]# ll /svn/
total 0
drwxr-xr-x. 2 root root 6 Sep 21 11:18 branch
drwxr-xr-x. 2 root root 6 Sep 21 11:18 tag
drwxr-xr-x. 2 root root 6 Sep 21 11:18 trunk
将trunk:主干 branch:分支 tag:标记导入到svn服务器:
[root@xiaoyu ~]# svn import /svn svn://192.168.1.10/project -m "import"
Adding /svn/branch
Adding /svn/trunk
Skipped '/svn/.svn'
Adding /svn/tag
提示:
==>如果本地是svn服务器,等价于:svn import /svn file:///application/svndata/project -m "import"
6.svn copy:从trunk主干复制到分支branch:[root@xiaoyu svn]# svn copy svn://192.168.1.10/project svn://192.168.1.10/project/branch/branch_01 -m "create a branch from trunk" --username=xiaoyu --password=123456
Committed revision 12.