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]#