linux系統從SVN服務端下載、提交、更新、查看、拷貝、匯入項目代碼

來源:互聯網
上載者:User

關於linux系統下svn用戶端命令svn,我們可以通過–help去查看一些具體用法。其中最常見的則為checkout(co)、commit(ci)、update(up)、list(ls)等幾個,這些命令是非常重要的,以後需要shell或其他指令碼自動化來實現自動化。其中help的內容如下:

[root@servermanager svndata]# svn --help
usage: svn subcommond [options] [args]
Subversion command-line client, version 1.7.14.
Type 'svn help ' for help on a specific subcommand.
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)
   upgrade
 
Subversion is a tool for version control.
For additional information, see http://subversion.apache.org/
可見svn命令格式為:
svn subcommond  [options] [args] 其中子命令就是如上顯示。這裡我們簡單做幾個例子進行說明。
1,從svn服務端下載資料到本機伺服器。

[root@servermanager svndata]# svn  co  svn://59.46.xx.xx/demo  /data/svndata  --username=21yunwei  --password=xxxxxx
 
-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:
 
   <svn://59.46.80.248:3690> 2d5821a4-0759-41c1-95b7-251f2fbabe15
 
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    test
A    alltask.bat
A    alltask.vbs
A    addtest.txt
A    backup.bat
Checked out revision 9.
[root@servermanager svndata]# ll
total 32
-rw-r--r--. 1 root root     0 Aug 29 22:37 addtest.txt
-rw-r--r--. 1 root root     8 Aug 29 22:37 alltask.bat
-rw-r--r--. 1 root root 20671 Aug 29 22:37 alltask.vbs
-rw-r--r--. 1 root root     8 Aug 29 22:37 backup.bat
drwxr-xr-x. 2 root root     6 Aug 29 22:37 test
2,linux用戶端向svn服務端提交資料
我們建立一個svnlinux.php檔案,然後提交到svn服務端。

[root@servermanager svndata]# vim   svnlinux.php
[root@servermanager svndata]# svn add svnlinux.php
A         svnlinux.php
[root@servermanager svndata]# svn ci -m "svn data add test"
Adding         svnlinux.php
Transmitting file data .
Committed revision 17.
提交以後我們使用TortoiseSVN更新查看一下:
1
提交並更新成功。

3,從svn服務端更新資料到本機伺服器。

[root@servermanager  svndata]# svn  update   svn://59.46.xx.xx/demo  /data/svndata  --username=21yunwei  --password=xxxxxx
Skipped 'svn://59.46.80.248/sadoc'
A    /home/svndata/testlinux
Updated to revision 14.
Summary of conflicts:
  Skipped paths: 1
當然,也可以本機伺服器實現從svn本地拷貝:

[root@niaoyun43442 home]# svn co file:///application/svndata/sadoc/
A    sadoc/test
A    sadoc/testlinux
A    sadoc/alltask.bat
A    sadoc/alltask.vbs
A    sadoc/addtest.txt
A    sadoc/backup.bat
A    sadoc/21yunweitest.jnt
A    sadoc/addtest - 副本.txt
Checked out revision 15.
 
[root@niaoyun43442 home]# ll demo/
total 48
-rw-r--r-- 1 root root  4544 Aug 30 08:12 21yunweitest.jnt
-rw-r--r-- 1 root root     0 Aug 30 08:12 addtest.txt
-rw-r--r-- 1 root root     0 Aug 30 08:12 addtest - 副本.txt
-rw-r--r-- 1 root root     8 Aug 30 08:12 alltask.bat
-rw-r--r-- 1 root root 20671 Aug 30 08:12 alltask.vbs
-rw-r--r-- 1 root root     8 Aug 30 08:12 backup.bat
drwxr-xr-x 3 root root  4096 Aug 30 08:12 test
drwxr-xr-x 3 root root  4096 Aug 30 08:12 testlinux
4,從用戶端查看svn服務端內容以及如何查看指定檔案內容

[root@servermanager svndata]# svn ls  svn://59.46.xx.xx/demo
21yunweitest.jnt
addtest - 副本.txt
addtest.txt
alltask.bat
alltask.vbs
backup.bat
test/
testlinux/
addtest.txt
alltask.bat
alltask.vbs
[root@servermanager svndata]# svn cat svn://59.46.xx.xx/demo/addtest.txt
hello svn,add test.
注意:如果想查看詳細檔案屬性,可以加參數–verbose 顯示如下:

[root@servermanager svndata]# svn ls  svn://59.46.xx.xx/demo  --verbose
     16 21yunwei              Aug 30 08:26 ./
     15 21yunwei         4544 Aug 30 08:10 21yunweitest.jnt
     16 21yunwei            9 Aug 30 08:26 addtest.txt
     16 21yunwei            9 Aug 30 08:26 addtest.txt.bak
      8 21yunwei            8 Aug 30 08:11 alltask.bat
      6 21yunwei        20671 Aug 30 08:01 alltask.vbs
      9 21yunwei            8 Aug 30 08:12 backup.bat
      9 21yunwei              Aug 30 08:12 test/
     14 21yunwei              Aug 30 08:07 testlinux/
 
5,從用戶端如何import匯入項目資料到SVN服務端版本庫項目

首先,我們先建立項目目錄並上傳一些資料進去:

[root@servermanager  svndata]# mkdir -p /home/svndata/{trunk,branch,tag}
建立新項目21yunweinew並將剛才的資料目錄匯入進版本庫:

[root@servermanager   svndata]# svnadmin  create /svndata/21yunweinew
[root@servermanager  svndata]# svn import  /home/svndata/  file:///svndata/21yunweinew/ -m "import project  discuz"
Adding         /home/svndata/trunk
Adding         /home/svndata/tag
Adding         /home/svndata/branch
匯入項目成功。
1

6,從用戶端如何拷貝一個版本庫到SVN服務端另一個版本庫項目

[root@servermanager   21yunweinew]# svn copy  svn://59.46.xx.xx/21yunweinew/trunk svn://59.46.xx.xx/21yunweinew/branch/branch_21yunwei_20160830 -m "cp 21yunweinew trunk to branch"  --username=21yunwei --password=xxxxxx
拷貝成功Committed revision 3.
使用工具同步資料到本地查看如下:

1
當然後邊還有一些delete刪除等等,這裡就不一一示範,可以自行操作測試下。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.