windows下搭建svn服務器


1、從官網下載svn服務端和客戶端;

2、安裝服務端和客戶端,安裝客戶端后要求重啟;

3、建立版本庫(repository)

方法一:命令行方式

首先,在E盤下建立svnroot文件夾,

然后,打開命令窗口,鍵入

svnadmin create E:\svnroot\repository

這樣就會在E:\svnroot目錄下創建repository文件夾,並在repository文件夾下生成相應文件。(注意不能遞歸創建,E:\svnroot必須事先建立好)

 

 

方法二:圖形化方式

仍然新建E:\svnroot\repository文件夾,這里repository文件夾必須是空的。

進入repository文件夾,右鍵選擇TortoiseSVN->Create repository here,如下圖

兩種方式都可以創建版本庫,結果像下面這樣:

4、修改配置文件

在E:\svnroot\repository\conf下,會看到有authz、passwd和svnserve.conf三個文件,這里我們會修改svnserve.conf和passwd這兩個配置文件。

對svnserve.conf修改如下:

### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.apache.org/ for more information.

[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete 
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = read 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 = 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 ### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
# realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

即使anon-access = read、auth-access = write和password-db = passwd生效,注意不要取消authz-db = authz的注釋,否則后面會認證失敗。

各字段的含義注釋里面有詳細說明。

 

對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
jack = jack

這里我們添加了一個用戶jack,密碼是jack。格式是user = passwd,每個賬號一行。

5、啟動subversion服務

方法一、命令行啟動

在命令行鍵入

svnserve -d -r E:\svnroot\repository

-d/--daemon:以守護進程的方式運行

-r/--root:設置svn://localhost,這里svn://localhost為E:\svnroot\repository

默認端口是3690,如果這個端口號已經被占用,則可以通過選項 --listen-port=端口號來設置。

方法二、windows服務啟動

安裝程序還不能把自己安裝成windows服務,需要自己進行手動安裝,方法如下: 打開命令窗口,執行如下命令:

sc create svnserve binPath="F:\Develop\Subversion\bin\svnserve.exe --service -r e:\svnroot\repository" displayname="Subversion" depend=Tcpip start=auto

執行成功的話,會顯示

[SC] CreateService 成功

命令中各參數的解釋:

  • sc是windows自帶的服務配置程序,
  • 參數binPath表示svnserve可執行文件的安裝路徑,如果安裝路徑含有空格,請進行轉義,如
binPath="\"F:\Program Files\Subversion\bin\svnserve.exe\" --service -r d:\svnroot\repository"
  • --service參數表示以windows服務的形式運行,
  • -r/--root指明svn repository的位置,service參數與root參數都作為binPath的一部分,因此與svnserve.exe的路徑一起被包含在一對雙引號當中,而這對雙引號不需要進行轉義。
  • displayname表示在windows服務列表中顯示的名字
  • depend=Tcpip 表示svnserve服務的運行需要tcpip服務
  • start=auto表示開機后自動運行
  • 若要卸載svn服務,則執行 sc delete svnserve 即可

Win+R,鍵入services.msc回車,會看到剛剛創建的服務Subversion:

安裝服務后,svnserve要等下次開機時才會自動運行,當然我們也可以現在手動啟動此服務。

6、初始化導入項目

(1)選擇需要導入的項目

(2)插入URL和message

需要注意的是,這一步操作可以完全在另一台安裝了TortoiseSVN的主機上進行。例如運行svnserve的主機的IP是133.96.121.22,則URL部分輸入的內容就是“svn://133.96.121.22/”。

(3)鍵入用戶名和密碼

(4)成功導入文件

 

至此我們基本完成了svn服務端的安裝、配置、啟、導入項目等一系列操作。下面介紹一些基本操作。

 

1、取出(check out)

取出版本庫到一個工作拷貝:

任意建立一個空文件夾如work,右鍵->SVN Checkout,在“URL of repository”中輸入“svn://localhost/CppProj”,這樣我們就得到了一份 CppProj中內容的工作拷貝。

 

現在work文件夾圖標如下,可以發現左下角多了個對勾。

work文件夾內容如下,可以發現是CppProj工程的內容。

 

2、存入(check in)/提交(commit)

在工作拷貝中作出修改並提交:

 

文件一旦被修改,則在圖標左下角會有一個修改標志,如下途中main.cpp:

 

此時“右鍵 -> SVN Commit... ”,我們就把修改提交到了版本庫,版本庫根據情況存儲我們提交的數據。

 

在修改過的文件上“右鍵 -> TortoiseSVN -> Show Log” ,可以看到對這個文件所有的提交。

在不同的 revision 條目上“右鍵 -> Compare with working copy”,我們可以比較工作拷貝的文件和所選 revision 版本的區別。

 

 

此時,我們在work文件夾上“右鍵 -> TortoiseSVN -> Show Log”,選擇一個revision,就可以導出之前的版本

 

ref:

http://sjsky.iteye.com/blog/850804

http://www.jb51.net/article/29004.htm

http://clayz.iteye.com/blog/151063


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM