svn Linux下常用命令总结

svn linux常用命令   Shell/Python  

1、将文件checkout到本地目录
svn checkout http://192.168.0.10/svn/project project
简写:svn co
例: 如何导出SVN库文件不受本地SVN管理
svn export project /data/project

2、往版本库中添加新的文件
svn add file
svn add *.txt

3、将改动的文件提交到版本库
svn commit -m “LogMessage“
例如:
svn commit -m “add test file for my test“ test.txt
简写:svn ci

4、加锁/解锁
svn lock -m “LockMessage“ PATH
例如:
svn lock -m “lock test file“ test.txt
svn unlock PATH

5、更新到某个版本
svn update -r version path
例如:
svn update 如果后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本。
svn update -r 200 test.txt(将版本库中的文件test.txt还原到版本200)
简写:svn up

6、查看文件或者目录状态
svn status path

[?:不在svn的控制中;M:内容被修改;C:发生冲突;A:预定加入到版本库;K:被锁定]

7、删除文件
svn delete path -m “delete test fle“
例如:
svn delete http://192.168.0.10/svn/project/test.txt -m “delete test file”
或者 svn delete test.php 然后 svn ci -m ‘delete test file‘
简写:svn (del, remove, rm)

8、查看日志
svn log path
例如:
svn log test.txt显示这个文件的所有修改记录和版本号的变化

9、查看文件详细信息
svn info path
例如:
svn info test.php

10、比较差异
svn diff path
例如:
svn diff test.php 将修改的文件与基础版本比较
svn diff -r m:n path (对版本m和版本n比较差异)
例如:
svn diff -r 200:201 test.php
简写:svn di

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

12、SVN 帮助
svn help
svn help ci

13、SVN冲突问题

(e)  edit             - change merged file in an editor               #直接进入编辑 
(df) diff-full        - show all changes made to merged file          #显示更改至目标文件的所有变化 
(r)  resolved         - accept merged version of file 
(dc) display-conflict - show all conflicts (ignoring merged version)  #显示所有冲突 
(mc) mine-conflict    - accept my version for all conflicts (same)    #冲突以本地为准 
(tc) theirs-conflict  - accept their version for all conflicts (same) #冲突以服务器为准 

(mf) mine-full        - accept my version of entire file (even non-conflicts)#完全以本地为准 
(tf) theirs-full      - accept their version of entire file (same)    #完全以服务器为准 

(p) postpone          - mark the conflict to be resolved later        #标记冲突,稍后解决 
(l)  launch           - launch external tool to resolve conflict 
(s)  show all         - show this list 

14、简易搭建SVN服务器
example:
SVN 库目录 /home/svn_repo
SVN 项目 project_Aproject_B
搭建
svnserve -d -r /home/svn_repo/ 启动SVN服务
svnadmin create /home/svn_repo/project_A SVN库中创建一个项目
配置
/home/svn_repo/project_A/conf/passwd 用户密码
leoiceo:123456
/home/svn_repo/project_A/conf/authz 权限控制
[groups] #用户组
me = leoiceo
[project_A:/] #库权限
@me = rw
leoiceo = rw
访问
svn://ip/project_A/