SVN的Windows和Linux客户端操作详解

           SVN的Windows和Linux客户端操作详解

                                     作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

一.Windows客户端操作

1.安装SVN客户端

  a>.去官网下载svn软件包并安装:

                      

                      

                            

                            

                            

                            

                            

                            

  b>.验证安装是否成功:

    温馨提示,在虚拟机环境下安装SVN,可能需要重启虚拟机才会有“SVN Checkout”哟~

                      

2.配置下载SVN内容

  a>.创建或选择本地的目录作为svn同步工作目录(自己可以随意指定),创建一个新的目录为:“E:\yinzhengjie\workhome”,然后进入到该目录,右击鼠标,选择"SVN Checkout...",如下图:

                      

  b>.设置SVN地址,如下图:

                      

  c>.输入用户名与密码(SVN配置文件【passwd】中定义的哟),并可以勾选保存,如下图:

                            

  温馨提示:

    

  d>.开始下载同步,如下图:

                      

   e,同步完成后,如果你的SVN目录中文件的左下角有一个带绿色的对勾表示下载OK了,如下图:

                            

 1 扩展小知识: 
 2 
 3    进度对话框使用颜色代码来高亮显示不同的提交行为。
 4 
 5        1>.蓝色:提交一个修改
 6 
 7        2>.紫色:提交一个新增项
 8 
 9        3>.深红:提交一个删除或是替换
10 
11        4>.黑色:所有其他项
12 
13   这是默认的配合方案,但你可以通过设置对话框来定制这个颜色。

 

3.定期下载【uptate】SVN内容

  可能用过SVN的小伙伴都知道,每次到单位第一件事情就是同步数据,这样始终可以保持拿到的数据是最新的。 两年前,我在北龙中网工作时,就是用的SVN服务器,那也是我第一次接触SVN这个软件。

                   

 

4.向SVN服务器提交数据

                      

                      

                      

                      

 

5.查看服务器的文件 

    有可能本地的文件和服务器的文件不一致,在update的时候可以进行一个对比操作,还有就是上传完毕之后,建议要用以下的方法验证一下,看一下服务器的数据是否正常。

                      

                      

6.删除文件

                      

                      

                      

                      

                      

7.查看SVN目录或文件的历史版本

  a>.在SVN客户端的工作目录中点击鼠标右键,选择“TortoiseSVN”,然后选择“Show log”,如下图:

                

  b>.在弹出的窗口列表中煤科院看到历次修改的注释信息

                    

                     

 

二.Linux客户端操作

1.导入svn原始目录树

 1 [root@yinzhengjie ~]# mkdir -pv /data/yinzhengjie
 2 
 3 [root@yinzhengjie ~]# cd /data/yinzhengjie/
 4 
 5 [root@yinzhengjie yinzhengjie]# mkdir trunk branch tags -p
 6 
 7 [root@yinzhengjie yinzhengjie]#
 8 
 9 [root@yinzhengjie yinzhengjie]# tree /data/yinzhengjie/
10 
11 /data/yinzhengjie/
12 
13 ├── branch
14 
15 ├── tags
16 
17 └── trunk
18 
19  
20 
21 3 directories, 0 files
22 
23 [root@yinzhengjie yinzhengjie]#
24 [root@yinzhengjie yinzhengjie]# svn import svn://127.0.0.1/jky -m "import tree"
25 上面的属于网络的导入方式,也可以用本地的导入方式(可以里理解是windows的commit)
26 [root@yinzhengjie yinzhengjie]# svn import file:///yinzhengjie/application/svndata/jky/
27 可以用windows客户端进行验证一下。

                                

                                 

2.从SVN库提取数据

 1 [root@yinzhengjie yinzhengjie]# mkdir -p /data/test/
 2 [root@yinzhengjie yinzhengjie]# cd /data/test/
 3 [root@yinzhengjie test]# ll
 4 total 0
 5 [root@yinzhengjie test]# 
 6 [root@yinzhengjie test]# svn checkout svn://127.0.0.1/jky /data/test/ --username yinzhengjie --password  123
 7 A    /data/test/trunk
 8 A    /data/test/branch
 9 A    /data/test/TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
10 A    /data/test/tags
11 Checked out revision 2.
12 [root@yinzhengjie test]# ll
13 total 17924
14 drwxr-xr-x 3 root root     4096 Sep 25 09:00 branch
15 drwxr-xr-x 3 root root     4096 Sep 25 09:00 tags
16 -rw-r--r-- 1 root root 18341888 Sep 25 09:00 TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
17 drwxr-xr-x 3 root root     4096 Sep 25 09:00 trunk
18 [root@yinzhengjie test]# 
19 [root@yinzhengjie test]# ll
20 total 17924
21 drwxr-xr-x 3 root root     4096 Sep 25 09:00 branch
22 drwxr-xr-x 3 root root     4096 Sep 25 09:00 tags
23 -rw-r--r-- 1 root root 18341888 Sep 25 09:00 TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
24 drwxr-xr-x 3 root root     4096 Sep 25 09:00 trunk
25 [root@yinzhengjie test]# 
26 [root@yinzhengjie test]# svn update svn://127.0.0.1/jky /data/test/ --username yinzhengjie --password  123
27 Skipped 'svn://127.0.0.1/jky'
28 A    /data/test/11111111111111111.jpg
29 Updated to revision 3.
30 Summary of conflicts:
31   Skipped paths: 1
32 [root@yinzhengjie test]# 
33 [root@yinzhengjie test]# svn co svn://127.0.0.1/jky /data/test/ 
34 Checked out revision 3.
35 [root@yinzhengjie test]# ll
36 total 17948
37 -rw-r--r-- 1 root root    21386 Sep 25 09:05 11111111111111111.jpg
38 drwxr-xr-x 3 root root     4096 Sep 25 09:00 branch
39 drwxr-xr-x 3 root root     4096 Sep 25 09:00 tags
40 -rw-r--r-- 1 root root 18341888 Sep 25 09:00 TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
41 drwxr-xr-x 3 root root     4096 Sep 25 09:00 trunk
42 [root@yinzhengjie test]# 

                          

                          

3.查看SVN服务器中的数据

 1 [root@yinzhengjie test]# svn list --verbose svn://127.0.0.1/jky
 2       3 yinzheng              Sep 25 09:04 ./
 3       3 yinzheng        21386 Sep 25 09:04 11111111111111111.jpg
 4       1 yinzheng     18341888 Sep 25 07:55 TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
 5       2 yinzheng              Sep 25 08:49 branch/
 6       2 yinzheng              Sep 25 08:49 tags/
 7       2 yinzheng              Sep 25 08:49 trunk/
 8 [root@yinzhengjie test]# 
 9 [root@yinzhengjie test]# svn ls --verbose svn://127.0.0.1/jky
10       3 yinzheng              Sep 25 09:04 ./
11       3 yinzheng        21386 Sep 25 09:04 11111111111111111.jpg
12       1 yinzheng     18341888 Sep 25 07:55 TortoiseSVN-1.9.5.27581-x64-svn-1.9.5.msi
13       2 yinzheng              Sep 25 08:49 branch/
14       2 yinzheng              Sep 25 08:49 tags/
15       2 yinzheng              Sep 25 08:49 trunk/
16 [root@yinzhengjie test]# 
17 [root@yinzhengjie test]# svn --help

 

4.查看SVN服务器某个文件的内容

1 [root@yinzhengjie test]# svn cat  svn://127.0.0.1/jky/尹正杰博客.txt
2 http://www.cnblogs.com/yinzhengjie/
3 [root@yinzhengjie test]# 

 

5.向SVN中提交数据

 1 [root@yinzhengjie ~]# cat /var/log/messages > /data/test/branch/test.log
 2 [root@yinzhengjie ~]# 
 3 [root@yinzhengjie ~]# svn add /data/test/branch/test.log 
 4 A         /data/test/branch/test.log
 5 [root@yinzhengjie ~]# 
 6 [root@yinzhengjie ~]# svn ci -m "upload test.log"
 7 svn: '/root' is not a working copy
 8 [root@yinzhengjie ~]# 
 9 [root@yinzhengjie ~]# cd /data/test/branch/
10 [root@yinzhengjie branch]# ll
11 total 4
12 -rw-r--r-- 1 root root 150 Sep 25 09:20 test.log
13 [root@yinzhengjie branch]# 
14 [root@yinzhengjie branch]# 
15 [root@yinzhengjie branch]# svn ci -m "upload test.log"
16 Adding         branch/test.log
17 Transmitting file data .
18 Committed revision 7.
19 [root@yinzhengjie branch]# 

                      

 

posted @ 2017-09-26 08:03  尹正杰  阅读(15251)  评论(2编辑  收藏  举报