1、安裝svn客戶端 1.1、使用命令安裝 1)CentOS 2)ubuntu 1.2、源碼安裝 http://www.cnblogs.com/fengbohello/p/4142810.html 2、開啟svn服務進程 2.1、我的習慣是把代碼倉庫放在/opt/svn目錄下,所以先創建目錄/opt ...
1、安裝svn客戶端
1.1、使用命令安裝
1)CentOS
$ yum install subversion
2)ubuntu
sudo apt-get install subversion
1.2、源碼安裝
http://www.cnblogs.com/fengbohello/p/4142810.html
2、開啟svn服務進程
2.1、我的習慣是把代碼倉庫放在/opt/svn目錄下,所以先創建目錄/opt/svn
$ mkdir /opt/svn -p
2.2、開啟svn服務進程
svnserve -d -r /opt/svn/
這個命令的作用是開啟svn服務進程,並且把/opt/svn/目錄作為我們的svn服務的根目錄。以後,當我們要在客戶端checkout代碼的時候,svn服務進程就會從這裡開始進行查詢,類似於apache的/var/www/目錄的作用。
運行如下命令檢查svn服務是否開啟了。
# ps -ef | grep svn root 2572 1 0 09:22 ? 00:00:00 svnserve -d -r /opt/svn/
如果,出現以上結果,這說明svn服務正常開啟了。
2.3、創建我們的第一個代碼倉庫:firsttest
# cd /opt/svn/ # svnadmin create firsttest
這就創建了我們的第一個代碼倉庫,這個代碼倉庫的名字就叫做“firsttest”,可以看到其中的文件
# ls firsttest/ README.txt conf db format hooks locks
2.4、下麵對我們的代碼倉庫進行許可權設置
1)進入conf目錄
# cd firsttest/conf/
2)編輯svnserve.conf。這個文件是要告訴svn服務進程,我們的firsttest項目的認證許可權和認證需要的密碼文件以及認證文件的存放位置。
在第8行左右找到“[general]”,對其下麵的內容進行編輯
# vim svnserve.conf ### 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",
其中需要編輯的地方分別是
2.1)
### and "none". The sample settings below are the defaults. # anon-access = read # auth-access = write ### The password-db option controls the location of the password
修改為
### 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
註意,紅色的兩行前面不能有空格,否個svn會讀取失敗,下麵的修改也要註意這些。這個一定要註意
2.2)
### Uncomment the line below to use the default password file. # password-db = passwd ### The authz-db option controls the location of the authorization
改為
### Uncomment the line below to use the default password file. password-db = passwd ### The authz-db option controls the location of the authorization
2.3)
### Uncomment the line below to use the default authorization file. # authz-db = authz ### This option specifies the authentication realm of the repository.
修改為
### Uncomment the line below to use the default authorization file. authz-db = authz ### This option specifies the authentication realm of the repository.
對於一般的情況,修改到這裡就可以了,下麵的選項是加密選項等的加強版,這裡就不說了。
3)下麵修改passwd文件。
# vim passwd
3.1)找到“[users]”,在此選項下添加用戶“woshihehe”,“woshihehe”用戶對應的密碼是“123456”
[users] # harry = harryssecret # sally = sallyssecret woshihehe = 123456
4)修改authz文件
# vim authz
在最後添加兩行
# [repository:/baz/fuz] # @harry_and_sally = rw # * = r [/] woshihehe=rw
如果是所有人都可以checkout,那麼就要修改成* = rw
這兩行的意思是,目錄[/](代碼根目錄)下的所有文件,如果沒有特殊約定的話,woshihehe用戶將具有讀(r)和寫(w)的許可權。
3、下載代碼
假如我的svn伺服器的IP是192.168.1.105,在其它的機器上,執行如下代碼
# svn co svn://192.168.1.105:/firsttest --username woshihehe 認證領域: <svn://192.168.1.105:3690> My First Repository “woshihehe”的密碼:
那麼接下來輸入密碼就可以了
----------------------------------------------------------------------- 註意! 你的密碼,對於認證域: <svn://192.168.1.105:3690> My First Repository 只能明文保存在磁碟上! 如果可能的話,請考慮配置你的系統,讓 Subversion 可以保存加密後的密碼。請參閱文檔以獲得詳細信息。 你可以通過在“/root/.subversion/servers”中設置選項“store-plaintext-passwords”為“yes”或“no”, 來避免再次出現此警告。 ----------------------------------------------------------------------- 保存未加密的密碼(yes/no)?yes 取出版本 0。
填寫yes,這樣我們就取出了我們的代碼,版本是0。這時候就可以在裡面添加目錄和文件了。不過這個是如何使用svn了,這裡就細說了。