yum install -y subversion
mkdir -p /application/svndata
mkdir -p /application/svnpasswd
svnadmin create /appplication/svndata/sadoc
[root@root ~]# LANG=en
[root@root ~]# tree /appplication/svndata/sadoc
cd /application/svndata/sadoc
cp svnserve.conf svnserve.conf.ori
vim svnserve.concc
## access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = /application/svnpasswd/passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file. If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db =/authz
cp authz passwd /appplication/svnpasswd/
[root@root conf]# svnserve -d -r /appplication/svndata/
svnserve: warning: cannot set LC_CTYPE locale
svnserve: warning: environment variable LANG is en
svnserve: warning: please check that your locale name is correct
svnserve: Can't bind server socket: Address already in use
[root@root conf]# pkill svnserve
[root@root conf]# lsof -i :3690
[root@root conf]# svnserve -d -r /appplication/svndata/
svnserve: warning: cannot set LC_CTYPE locale
svnserve: warning: environment variable LANG is en
svnserve: warning: please check that your locale name is correct
[root@root conf]# lsof -i :3690
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
svnserve 4713 root 3u IPv4 28582 0t0 TCP *:svn (LISTEN)
cd /application/svnpasswd
vim passwd
[root@root svnpasswd]# cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
fjb = 123456
fjj = 123456
stu001 = 123
stu002 = 456
cat authz
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
xiyue = stu001,stu002
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[sadoc:/]
fjb = rw
fjj = r
@xiyue = r
cd /tmp
476 mkdir dir
477 cd dir/
478 mkdir stu{003..010}
479 svn import /tmp/dir/ svn://192.168.1.101/sadoc/ -m "import svntree"
[root@client dir]# cat passwd
cat: passwd: 沒有那個文件或目錄
[root@client dir]# cd /application/svnpasswd/
[root@client svnpasswd]# ll
總用量 8
-rw-r--r-- 1 root root 1200 3月 4 23:57 authz
-rw-r--r-- 1 root root 362 3月 4 23:16 passwd
[root@client svnpasswd]# cat authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
### - a single user,
### - a group of users defined in a special [groups] section,
### - an alias defined in a special [aliases] section,
### - all authenticated users, using the '$authenticated' token,
### - only anonymous users, using the '$anonymous' token,
### - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
xiyue = stu001,stu002
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
[sadoc:/]
fjb = rw
fjj = r
[sadoc:/stu001]
fjb = rw
stu001 = rw
[sadoc:/stu002]
stu002 =rw
fjb =rw
[root@client svnpasswd]# cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
fjb = 123456
fjj = 123456
stu001 = 123
stu002 = 456
linux svn 更新提交命令
linux下svn常用指令
一下內容轉載於:http://blog.chinaunix.net/space.php?uid=22976768&do=blog&id=1640924。這個總結的很好~
windows下的TortoiseSVN是資源管理器的一個插件,以覆蓋圖標表示文件狀態,幾乎所以命令都有圖形界面支持,比較好用,這裏就不多說。主要說說linux下svn的使用,因爲linux下大部分的操作都是通過命令行來進行,所以必須得掌握linux下svn的常用指令。當然linux下也有模仿TortoiseSVN的linux X程序,例如RabbitVCS,模仿程度很高,但很容易拖慢X,因此不推薦。
(如果是第一次提交文件,很可能會出現“svn:'.'不是工作副本”,即當前目錄不是工作副本,這個時候需要用到import:
eg:svn import . url)
1、將文件checkout到本地目錄
svn checkout path(path是服務器上的目錄)
例如:svn checkout svn://192.168.1.1/pro/domain
簡寫:svn co
2、往版本庫中添加新的文件
svn add file
例如:svn add test.php(添加test.php)
svn add *.php(添加當前目錄下所有的php文件)
3、將改動的文件提交到版本庫
svn commit -m “LogMessage“ [-N] [--no-unlock] PATH(如果選擇了保持鎖,就使用–no-unlock開關)
例如:svn commit -m “add test file for my test“ test.php
簡寫:svn ci
4、加鎖/解鎖
svn lock -m “LockMessage“ [--force] PATH
例如:svn lock -m “lock test file“ test.php
svn unlock PATH
5、更新到某個版本是v你
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
6、查看文件或者目錄狀態
1)svn status path(目錄下的文件和子目錄的狀態,正常狀態不顯示)
【?:不在svn的控制中;M:內容被修改;C:發生衝突;A:預定加入到版本庫;K:被鎖定】M狀態一般比較多
2)svn status -v path(顯示文件和子目錄狀態)
第一列保持相同,第二列顯示工作版本號,第三和第四列顯示最後一次修改的版本號和修改人。
注:svn status、svn diff和 svn revert這三條命令在沒有網絡的情況下也可以執行的,原因是svn在本地的.svn中保留了本地版本的原始拷貝。
簡寫:svn st
7、刪除文件
svn delete path -m “delete test fle“
例如:svn delete svn://192.168.1.1/pro/domain/test.php -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.php 顯示這個文件的所有修改記錄,及其版本號的變化
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 list path
顯示path目錄下的所有屬於版本庫的文件和目錄
簡寫:svn ls
14、創建納入版本控制下的新目錄
svn mkdir: 創建納入版本控制下的新目錄。
用法: 1、mkdir PATH…
2、mkdir URL…
創建版本控制的目錄。
1、每一個以工作副本 PATH 指定的目錄,都會創建在本地端,並且加入新增
調度,以待下一次的提交。
2、每個以URL指定的目錄,都會透過立即提交於倉庫中創建。
在這兩個情況下,所有的中間目錄都必須事先存在。
15、恢復本地修改
svn revert: 恢復原始未改變的工作副本文件 (恢復大部份的本地修改)。revert:
用法: revert PATH…
注意: 本子命令不會存取網絡,並且會解除衝突的狀況。但是它不會恢復
被刪除的目錄
16、代碼庫URL變更
svn switch (sw): 更新工作副本至不同的URL。
用法: 1、switch URL [PATH]
2、switch –relocate FROM TO [PATH...]
1、更新你的工作副本,映射到一個新的URL,其行爲跟“svn update”很像,也會將服務器上文件與本地文件合併。這是將工作副本對應到同一倉庫中某個分支或者標記的方法。
2、改寫工作副本的URL元數據,以反映單純的URL上的改變。當倉庫的根URL變動
(比如方案名或是主機名稱變動),但是工作副本仍舊對映到同一倉庫的同一目錄時使用
這個命令更新工作副本與倉庫的對應關係。
17、解決衝突
svn resolved: 移除工作副本的目錄或文件的“衝突”狀態。
用法: resolved PATH…
注意: 本子命令不會依語法來解決衝突或是移除衝突標記;它只是移除衝突的
相關文件,然後讓 PATH 可以再次提交。
18、輸出指定文件或URL的內容。
svn cat 目標[@版本]…如果指定了版本,將從指定的版本開始查找。
svn cat -r PREV filename > filename (PREV 是上一版本,也可以寫具體版本號,這樣輸出結果是可以提交的)