mac自帶了svn客戶端和服務端功能。
1.查看svn版本
svnserve --version
yintingtingdeMacBook-Pro:~ yintingting$ svnserve --version svnserve, version 1.9.4 (r1740329) compiled Nov 15 2016, 20:35:27 on x86_64-apple-darwin15.0.0 Copyright (C) 2016 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/ The following repository back-end (FS) modules are available: * fs_fs : Module for working with a plain file (FSFS) repository. * fs_x : Module for working with an experimental (FSX) repository.
2.創建svn目錄
sudo mkdir -p /Users/yintingting(根據自己的用戶名修改)/svn/mycode //創建了一個文件夾,這個文件夾路徑可以自己隨意設定
sudo svnadmin create /Users/yintingting(根據自己的用戶名修改)/svn/mycode //將之前創建的文件夾設置為svn的代碼庫
(下圖svn_dir相當於mycode文件夾的樣子)
3.
conf文件夾是配置文件夾,里面有相關配置,先選擇svnserve.conf配置,如下圖:
# anon-access = read
# auth-access = write
# password-db = passwd
# authz-db = authz
去掉這幾個前面的#和空格,
anon-access 表示匿名訪問權限(如果把anon-access=read修改為anon-access=none,這樣就禁止了匿名訪問,只有輸入賬號密碼才可以訪問)
4.
我們創建個帳戶,要進passwd文件配置,在[users]后面加ytt=123,表示創建了ytt帳戶,密碼是123.
### 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 ytt = 123
xsd = 123
5.文件authz可以配置用戶組及權限,可以把passwd里添加的用戶加到一個用戶組里或創建一個用戶組,這樣就可以對整個組設置權限了,還不用對每個用戶進行單獨權限設置。我們這里加了個zyxgroup組,包括用戶zyx,權限是對根目錄有讀寫權限,[/]表示根目錄。
修改文件時寫入不了就用vi編輯器,如果vi編輯器加了!還改不了,那就修改文件權限。
比如:切換到root用戶:sudo -i
讀寫權限:chmod 666 你的文件(777也行,隨便你,關鍵有w權限)
### 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 yttgroup = xsd,ytt # [/foo/bar] # harry = rw # &joe = r # * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r [/] @yttgroup=rw
6.啟動svn服務器
svnserve -d -r /Users/yintingting/svn
注意不要輸入svnserve -d -r /Users/yintingting/svn/mycode
7.關閉svn服務器的話,可以用ps找到它的pid,然后kill它就可以了。或者用活動監視器
ps -e | grep svnserve
5137 ?? 0:00.00 /Library/Developer/CommandLineTools/usr/bin/svnserve -d -r svn_dir
5142 ttys000 0:00.00 grep svnserve
kill 5137進程即可。
下面就是怎樣在eclipse中使用了。。。。。。。
1.eclipse裝上subclipse插件,help ->eclipse marketplace,搜索subclipse,安裝,注意下面勾選內容(最好subclipse和svnkit都選)
安裝成功,window->show view->other,會出現如下圖窗口
選擇SVN資源庫,點擊OK,下方出現svn資源庫
打開eclipse偏好設置,svn接口選一個(我這里選的是SVNKit,因為JavaHL(JNI) not available,而mac電腦用這個太麻煩),如果JavaHL可用那就用JavaHL好了。
切換到“SVN資源庫”,新建-》資源庫位置,
URL填寫svn://ytt@localhost/mycode (ytt是用戶名,之前創建的),在出來界面中輸入用戶名和密碼,OK.