你的位置:首页 > 操作系统

[操作系统]linux svn客户端 常用命令


查看文件或者目录状态:

[root@v01 ~]# svn status online/ #正常情况下没显示

 

[root@v01 ~]# svn status online/ #如果有变动会有如下显示【?:不在svn的控制中;M:内容被修改;C:发生冲突;A:预定加入到版本库;K:被锁定】M    online/index.html 

 

[root@v01 ~]# svn status -v online/ #svn status -v path(显示文件和子目录状态)         1    1 user001   onlineM        1    1 user001   online/index.html第一列保持相同,第二列显示工作版本号,第三和第四列显示最后一次修改的版本号和修改人。  注:svn status、svn diff和 svn revert这三条命令在没有网络的情况下也可以执行的,原因是svn在本地的.svn中保留了本地版本的原始拷贝。简写:svn st

 将改动的文件提交到版本库

[root@v01 ~]# cd online/[root@v01 online]# lsindex.html[root@v01 online]# svn commit -m "add test file for mytest" index.html Sending    index.htmlTransmitting file data .Committed revision 2.

 

[root@v01 ~]# svn status -v online/         1    1 user001   online         2    2 user001   online/index.html[root@v01 ~]# svn status online/[root@v01 ~]# 提交成功 客户段与服务端代码一致!
svn commit -m “LogMessage“ [-N] [--no-unlock] PATH(如果选择了保持锁,就使用–no-unlock开关)

 加锁/解锁

svn lock -m “LockMessage“ [--force] PATH例如:svn lock -m “lock test file“ test.phpsvn unlock PATH

 更新到某个版本

svn update -r m path例如:svn update如果后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本。svn update -r 200 test.php(将版本库中的文件test.php还原到版本200)svn update test.php(更新,于版本库同步。如果在提交的时候提示过期的话,是因为冲突,需要先update,修改文件,然后清除svn resolved,最后再提交commit)简写:svn up

 添加一个文件到工作拷贝:

$ svn co http://host/myproject working_copy # Substitute for whatever URL you need to access your repository.$ cd working_copy$ mkdir sample$ svn add sample$ svn ci -m "Commit!"

 

[root@v01 www]# cp authz webtest/[root@v01 www]# svn status webtest/?    webtest/authz[root@v01 www]# cd webtest/[root@v01 webtest]# lsauthz index.html index.php[root@v01 webtest]# svn add authz A     authz

 

[root@v01 www]# svn add webtest/ index.html svn: '.' is not a working copy--------------------------------------------------------------------------[root@v01 www]# ll -all webtest/total 12drwxr-xr-x. 3 www www 4096 May 9 08:49 .dr-xr-xr-x. 5 www www 4096 May 9 08:49 ..drwxr-xr-x. 6 root root 4096 May 9 08:47 .svn[root@v01 webtest]# tree ..├── index.html└── index.php0 directories, 2 files[root@v01 www]# cp index.{html,php} webtest/cp: overwrite `webtest/index.html'? ycp: overwrite `webtest/index.php'? y[root@v01 www]# svn status -v webtest/         0    0 ?      webtestA        0    ?  ?      webtest/index.htmlA        0    ?  ?      webtest/index.php[root@v01 www]# svn status webtest/A    webtest/index.htmlA    webtest/index.php

 

[root@v01 webtest]# svn ci svn: Commit failed (details follow):svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) optionssvn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found

 

追加到/etc/bashrcexport SVN_EDITOR=vim

 

[root@v01 webtest]# source /etc/bashrc [root@v01 webtest]# svn ci sh: vim: command not foundsvn: Commit failed (details follow):svn: system('vim svn-commit.tmp') returned 32512

 

[root@v01 webtest]# svn ciLog message unchanged or not specified(a)bort, (c)ontinue, (e)dit:cAuthentication realm: <svn://192.168.1.89:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73Password for 'root': Authentication realm: <svn://192.168.1.89:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73Username: user01Password for 'user01': -----------------------------------------------------------------------ATTENTION! Your password for authentication realm:  <svn://192.168.1.89:3690> 18ab87c6-8455-4174-a313-7b6fd3775a73can only be stored to disk unencrypted! You are advised to configureyour system so that Subversion can store passwords encrypted, ifpossible. See the documentation for details.You can avoid future appearances of this warning by setting the valueof the 'store-plaintext-passwords' option to either 'yes' or 'no' in'/root/.subversion/servers'.-----------------------------------------------------------------------Store password unencrypted (yes/no)? yesAdding     index.htmlAdding     index.phpTransmitting file data ..Committed revision 1.

 

[root@v01 webtest]# echo "hello world" >> index.html [root@v01 webtest]# svn status?    svn-commit.tmpM    index.html[root@v01 webtest]# svn ciLog message unchanged or not specified(a)bort, (c)ontinue, (e)dit:cSending    index.htmlTransmitting file data .Committed revision 3.

 查看日志:

svn log path例如:svn log test.php 显示这个文件的所有修改记录,及其版本号的变化[root@v01 webtest]# svn log index.html------------------------------------------------------------------------r3 | user01 | 2016-05-09 11:40:24 +0800 (Mon, 09 May 2016) | 1 line------------------------------------------------------------------------r2 | user01 | 2016-05-09 11:39:21 +0800 (Mon, 09 May 2016) | 1 line------------------------------------------------------------------------r1 | user01 | 2016-05-09 11:33:04 +0800 (Mon, 09 May 2016) | 1 line-----------------------------------------------------------------------

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

[root@v01 webtest]# svn info index.html Path: index.htmlName: index.htmlURL: svn://192.168.1.89/webtest/index.htmlRepository Root: svn://192.168.1.89/webtestRepository UUID: 18ab87c6-8455-4174-a313-7b6fd3775a73Revision: 3Node Kind: fileSchedule: normalLast Changed Author: user01Last Changed Rev: 3Last Changed Date: 2016-05-09 11:40:24 +0800 (Mon, 09 May 2016)Text Last Updated: 2016-05-09 11:40:03 +0800 (Mon, 09 May 2016)Checksum: 6f9361a19c3f7bb3c06d0fdadbfe479b

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

[root@v01 webtest]# svn di -r 1:3 index.html Index: index.html===================================================================--- index.html	(revision 1)+++ index.html	(revision 3)@@ -1 +1,2 @@-testweb+kkkkkkkkkkktestweb+hello world[root@v01 webtest]# svn di -r 1:2 index.html Index: index.html===================================================================--- index.html  (revision 1)+++ index.html  (revision 2)@@ -1 +1 @@-testweb+kkkkkkkkkkktestweb[root@v01 webtest]# svn di -r 2:3 index.html Index: index.html===================================================================--- index.html  (revision 2)+++ index.html  (revision 3)@@ -1 +1,2 @@ kkkkkkkkkkktestweb+hello world[root@v01 webtest]#