2018-09-11 Svn升級Git不需要那麼痛
一. 介紹
SubGit是用java語言編寫的。SubGit是一種subversion與git程式碼庫之間雙向同步工具。如何在本地subversion版本庫上安裝SubGit請參考下片文章。本片文章主要說明使用SubGit建立git映象遠端subversion版本庫。
通常情況下,subversion版本庫是通過網路訪問的,如http(s)、svn、svn+SSH、本地檔案系統。相應地,使用者請求是通過apache web伺服器、svnserve守護程式、sshd守護程式呼叫svnserve程式。如下圖所示:
使用者使用subgit來建立和配置git版本庫,與遠端的subversion版本庫保持同步。每一個git庫映象一個subversion專案,也有可能是多個專案包含在單個subversion版本庫中。程式碼的更改推到git版本庫上,會立馬轉換到subversion專案上。反之亦然,subversion專案的提交也會反映到相對應的git版本庫上。
或者,可以在subversion端啟用程式碼庫的pre-revprop-change鉤子功能,這將使subgit使用單一的subversion使用者賬號,不過這種修改是不需要的,所以即使subversion版本庫,你沒有shell訪問通過subgit來映象。下圖顯示了典型的subgit建立,通過subgit來建立一個遠端subversion版本庫的git映象:
在映象初始化階段,subgit轉換現有的subversion修訂本到一個新建立的git倉庫上。還有一種方法,跳過映象,一次性的從subversion匯入到git。
小結:
1. subgit建立git倉庫,映象於遠端的subversion版本庫
2. subgit可一次性從subversion匯入到git
3. 不需要直接shell訪問subversion版本庫
4. subgit授予使用者選擇是否使用git還是subversion,提供平滑遷移路徑
5. subgit使用java語言實現的,因此需要java1.5版本及以上
二. subgit特性
主要好處有:
1. 強大的轉換和初始的匯入效能(與git-svn對比 參見http://www.ttlsa.com/html/1864.html)
2. 沒有限制(與git-svn相反)
3. 不需要shell訪問subversion版本庫
subgit包含強大的轉換引擎,將轉化:
1. 合併跟蹤資訊和歷史
2. 非線性git提交歷史到subversion
3. 子專案、標籤和分支
4. svn:ignore 和 .gitignore忽略定義
5. svn:eol-style 和 .gitattributes特殊屬性
6. 符號連結
7. 提交作者和日期
8. 檔案和目錄重新命名
三. 映象配置介紹
要同步subversion和git版本庫,subgit對映一個系統的實體到另一個。一個git倉庫總是對映到subversion版本庫上的一個單一的專案。也有可能是有一種到多種專案的subversion版本庫。git庫包含subgit以下的資訊和對映配置:
1. subversion專案在subversion版本庫的位置
2. subversion專案的分支和標籤對映到git的分支和標籤引用
3. subversion使用者對映到git提交者
上面的對映是在轉換和同步開始之前的靜態配置。所有的對映和其他資訊儲存在GIT_REPOS/subgit目錄下。下面的各界將介紹這些對映的詳細資訊。
3.1 subversion專案位置
subversion版本庫可能包含一個或多個專案。每個專案推薦使用subversion版本庫佈局,如trunk、branches、tags子目錄
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 60px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
|
/project
/trunk # 專案主線
/branches # 包含專案功能和版本分支,從trunk或其他branches複製過來的
/tags # 包含專案標籤,trunk和branches的快照
|
並不是非得要trunk、branches和tags資料夾,但是這些資料夾的作用是很重要的。
下圖所示每個專案對映到一個空的git庫
Single Project Repository Mapping
SubGit configuration file (single project mapping)
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 60px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
|
[svn]
URL that points to a project root
(may be the same as Subversion repository root)
url = http://host/svn/repos
|
Multiple Projects Repository Mapping
SubGit configuration file (two projects mapping)
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 180px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
|
/var/git/project1.git/subgit/config
[svn]
# project location within Subversion repository
url = http://host/svn/repos/project1
...
/var/git/project2.git/subgit/config
[svn]
# project location within Subversion repository
url = http://host/svn/repos/project2
|
3.2 Branches 和 Tags對映
對於每一個專案對映到一個git庫,branches和tags對映到git庫中相對應引用。subgit區分subversion專案下的branches或tags資料夾:
1. trunk folder
2. 專用資料夾中的branches資料夾
3. 專用資料夾中的shelves資料夾
4. 專用資料夾中的tags資料夾
shelves是一種特殊的branches,給subgit使用的用於在subversion版本庫中代表git匿名的branches。
每個資料夾都對映到git庫中的引用。對於trunk資料夾,對映是一對一的。其他資料夾使用萬用字元對映。
每當專案使用標準的資料夾名稱如trunk、branches、tags,subgit將會自動檢測和配置該專案的對映。否則,配置將需要手工更改,包括適當的路徑和引用名稱。
Default Branches and Tags Mapping:
SubGit configuration file (default branches and tags mapping):
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 150px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
|
[svn]
url = http://host/svn/repos/project1
branches and tags mapping in form of
branchKind=Subversion-Path-Pattern:Git-Reference-Pattern
trunk = trunk:refs/heads/master
branches = branches/:refs/heads/
shelves = shelves/:refs/shelves/
tags = tags/:refs/tags/
|
SubGit configuration file (non-standard folders names):
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 150px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
|
[svn]
url = http://host/svn/repos/project2
branches and tags mapping in form of
branchKind=Subversion-Path-Pattern:Git-Reference-Pattern
trunk = main:refs/heads/master
branches = versions/:refs/heads/
shelves = shelves/:refs/shelves/
tags = stamps/:refs/tags/
|
3.3 作者對映
預設情況下,如果沒有明確的作者對映,轉換將使用下面的規則:
1. Subversion "svn_user_name" is translated to "svn_user_name <>" in Git
2. Git "Author Name email@domain.com" is translated to "Author Name" in Subversion
另外的預設規則,可以通過subgit配置來明確作者的對映。預設情況下,作者對映儲存在一個單獨的文字檔案GIT_REPOS/subgit/authors.txt
GIT_REPOS/subgit/authors.txt file:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
svn_user_name = Git Name name@email.com
|
可更變authors.txt儲存位置:
SubGit configuration file defines authors.txt location:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 75px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
|
[core]
...
location of the authors mapping file
authorsFile = subgit/authors.txt
...
|
作者的對映檔案內容可能會隨時改變,新的對映可能立即生效。
四. 一次性從subversion匯入到git
有時候沒必要保持git庫與subversion版本庫的同步,而直接一次性解決。subgit提供快捷的import命令,讓使用者在命令列中指定所有必要的選項,從而自動化批量匯入。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 570px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
subgit help import
info: Import SVN or Git repository.
usage: subgit import [--svn-url URL] [--default-domain DOMAIN] [--minimal-revision REV] [--authors-file FILE] [--trunk PATH] [--branches PATH] [--tags PATH] [--username SVN_USERNAME] [--password SVN_PASSWORD] [--non-interactive] [--trust-server-cert] [--private-key SVN_PRIVATE_KEY_PATH] [--private-key-passphrase SVN_PRIVATE_KEY_PASSPHRASE] REPOS_PATH
Import existing Subversion project at URL into Git repository at REPOS_PATH.
When Git repository at REPOS_PATH does not exist it will be created.
Upon import completion optionally one may get rid of SubGit-specific files
by running 'subgit uninstall --purge REPOS_PATH' or start continuous synchronization
by running 'subgit install REPOS_PATH'.
Valid options:
--svn-url URL : specify URL of remote Subversion repository
--default-domain DOMAIN : domain to be used to generate Git committer name by SVN committer name
if there's no corresponding rule in authors file
--minimal-revision REV : specify Subversion revision REV to start translation from;
revisions less than REV would not be translated
--authors-file FILE : authors mapping file used to map Subversion committers names
to Git committers names
-T [--trunk] PATH : path to a directory that plays the role of SVN trunk,
relative to project root specified by --svn-url
-b [--branches] PATH : path to a directory that plays the role of SVN branches directory,
relative to project root specified by --svn-url
-t [--tags] PATH : path to a directory that plays the role of SVN tags directory,
relative to project root specified by --svn-url
--username SVN_USERNAME : username to use to access Subversion repository;
if no username is specified, SubGit may prompt for it later
--password SVN_PASSWORD : password to use to access Subversion repository;
if no password is specified, SubGit may prompt for it later
--non-interactive : do no interactive prompting
--trust-server-cert : accept unknown SSL server certificates without
prompting (but only with '--non-interactive')
--private-key : path to private key file to use to access Subversion repository;
if no path is specified, SubGit may prompt for it later
--private-key-passphrase: passphrase for private key file to use to access Subversion repository;
if no passphrase is specified, SubGit may ask for it later
|
在大多數情況下,預先存在的subversion認證儲存就足夠了,唯一要指定subversion專案的URL引數:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 150px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
|
subgit import --non-interactive --svn-url http://svn.svnkit.com/repos/sqljet sqljet.git
SubGit version 2.0.0-EAP ('Patrick') build #2552
This is an EAP build, which you may not like to use in production environment.
Translating Subversion revisions to Git commits...
Subversion revisions translated: 1292.
Total time: 579 seconds.
IMPORT SUCCESSFUL
|
五. 建立subversion版本庫的git映象
5.1 安裝階段
subversion版本庫轉換到git庫和啟用雙向同步,其中一個必須使用subgit來建立和配置git庫。建立映象包括三個階段:建立庫、配置調整和安裝。
Mirror Creation Stages:
在配置階段,subgit建立git庫,預設的映象配置存入其中,然後使用者有機會調整生成配置。在安裝階段,subgit執行現有的subversion修訂轉換到git提交,同時啟動同步。
5.2 執行subgit配置
執行subgit配置命令使subgit建立空的git庫,並將其連結到subversion專案。
在執行配置命令時,使用者需要指定subversion專案URL,將從最低版本開始同步。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 120px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
|
subgit configure --svn-url http://svn.svnkit.com/repos/sqljet sqljet.git
SubGit version 2.0.0 ('Patrick') build #2552
Configuring writable Git mirror of remote Subversion repository:
Subversion repository URL : http://svn.svnkit.com/repos/sqljet
Git repository location : sqljet.git
CONFIGURATION SUCCESSFUL
|
在配置階段,subgit不會與subversion版本庫建立連線,但是生成配置檔案資訊在進行安裝時很有必要的。如下所示:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 225px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
git_repository/
branches
hooks
logs
objects
refs
subgit/
lib/ # SubGit binaries
logs/ # SubGit logs
authors.txt # default authors mapping (empty)
config # SubGit configuration file
passwd # Password credentials to access Subversion repository
format # Information on SubGit version
config # Git configuration file
HEAD
|
5.3 調整配置:介紹
subgit配置命令建立空的git庫,寫入預設配置,並對映到GIT_REPOS/subgit/config檔案。調整預設生成的配置,然後再進入安裝階段。在特定的使用者必須提供憑證或指定哪裡可以找到他們,以便於subgit訪問subversion版本庫。 預設生成的配置檔案如下所示:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 345px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[core]
authorsFile = subgit/authors.txt
pathEncoding = UTF-8
defaultDomain = tmatesoft.com
[svn]
url = http://svn.svnkit.com/repos/sqljet
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
fetchInterval = 60
connectTimeout = 30
readTimeout = 60
auth = default
[auth "default"]
passwords = subgit/passwd
useDefaultSubversionConfigurationDirectory = false
subversionConfigurationDirectory = /home/user/subversion
|
subgit/config可以指定相對的或絕對的路徑。相對路徑被視為相對git庫跟目錄。
5.4 調整配置:提供作者對映
將subversion使用者對映到git作者寫入到conf/authors.txt檔案。如下所示:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
conf/authors.txt:
semen = Semen Vadishev vadishev@tmatesoft.com
dmitry = Dmitry Pavlenko pavlenko@tmatesoft.com
|
或者指定以存在的作者對映檔案:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[core]
...
authorsFile = /var/git/company-authors-mapping.txt
|
指定作者對映檔案是core.authorsFile可選值。路徑相對於subversion版本庫跟(如conf/authors.txt對應於SVN_REPOS/conf/authors.txt)或指定絕對路徑。
為遺失的email指定預設域:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[core]
...
defaultDomain = company.com
|
email是git作者資訊的一部分, 在沒有找到作者對映或沒有提供email下,subgit將使用core.defaultDomain值來生成作者email.
5.5 調整配置:路徑編碼
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[core]
...
pathEncoding = UTF-8
|
git儲存路徑作為一個位元組序列,不指定編碼,通常是以本地檔案系統編碼。在subversion字串路徑轉化到git庫時,使用git.pathEncoding選項來指定編碼。大多數系統都被配置成utf-8編碼的。推薦配置此引數。
5.6 調整配置:branches對映
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[svn]
...
url = http://host/svn/repos
|
svn.url選項值指定專案位置。被用作跟URL來相對對映路徑。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 90px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
|
[svn]
...
trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
|
有四種分支必須對映,每個代表自身的選項:trunk、branches、tags、shelves。每個選項建立對應的SVN_PATH到GIT_REFERENCE特定種類實體,trunk對映語法如下:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
trunk = SVN_PATH:GIT_REFERENCE
|
svn.trunk選項允許指定單個SVN_PATH:GIT_REFERENCE對映作為它的值。SVN_PATH路徑相對於svn.url專案位置,GIT_REFERENCE是一個git參考,如refs/heads/master。對映的含義是在subversion專案中所做的更改將轉換到git提交GIT_REFERENCE。在GIT_REFERENCE提交將轉換更改到SVN_PATH。branches、tags、shelves對映語法如下:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
branches = SVN_PATH[/]:GIT_REFERENCE[/][;MAPPING]
|
這些選項允許指定多個對映,每個對映可以定義多對多的關係。對映可以是一對一或多對多的。換句話說,當使用萬用字元將對映到兩端。每個選項必須至少包含一個多對多的對映(其中帶萬用字元),例如:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
branches = branches/:refs/heads/;release_branhces/b1:refs/release/b1
|
上面的對映例項,subversion的所有branches目錄對映到git的refs/heads名稱空間,此外,release_branches/b1分支對映到git分支引用refs/releases/b1。
在指定對映時格外小心,在同步啟動時,不可能再調整的。通過subgit只有branches和tags所包含的對映將匯入並保持同步。
5.7 調整配置:憑證
為了在subversion版本庫中建立新的修訂版,subgit需要subversion伺服器的授權認證。subgit使用者可以提供多套憑證(使用者名稱/密碼對)。在建立新的修訂時,subgit可以選擇使用者名稱來授權。
GIT_REPOS/subgit/passwd檔案:subgit來讀取使用者名稱/密碼對。密碼是明文的。最好限制這個檔案的訪問許可權。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 60px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
|
username password
username1 secret
...
usernameN anothersecret
|
在subgit配置檔案中指定GIT_REPOS/subgit/passwd檔案路徑:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[auth "default"]
...
passwords = subgit/passwd
|
SubGit配置檔案:指定明確的ssh和ssl客戶端憑證
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 105px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
|
[auth "default"]
...
sshKeyFile = /home/user/ssh-private-key.openssh
sshKeyFilePassphrase = secret
sslClientCertFile = /home/user/ssl-client-cert.p12
sslClientCertPassphrase = secret
|
本地subversion憑證快取:為了使subgit可以從本地subversion憑證快取中讀取憑證,需要設定auth.useDefaultSubversionConfigurationDirectory選擇為true,同時需要指定快取檔案路徑。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 60px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
|
[auth "default"]
...
useDefaultSubversionConfigurationDirectory = true
subversionConfigurationDirectory = /home/user/.subversion
|
5.8 憑證和subversion pre-revprop-change鉤子
為建立新的subversion版本,subgit需要subversion伺服器驗證授權。為了做到這些,subgit遵循下面的演算法:
1. git的提交作者需和subversion作者匹配
2. 所有的源憑證配置迭代查詢作者憑證
3. 在憑證匹配情況下,subgit使用它們授權
4. 在憑證不匹配情況下,subgit使用任何可用的
5. 一旦提交新的修訂版,subgit設定該作者的svn:author修訂屬性
最安全配置subgit憑證的方式是提供單一的憑證,要麼明確指定subgit/passwd檔案,要麼指定本部subversion配置檔案路徑。然而,使用subversion版本屬性功能需要啟用subversion版本庫的pre-revprop-change鉤子。新增一個空的鉤子指令碼,退出程式碼為0來啟動修訂屬性:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 60px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
|
SVN_REPOSITORY/
hooks/
pre-revprop-change # for Linux and OS X
pre-revprop-change.bat # for Windows
|
Linux and OS X系統:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 30px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
|
!/bin/sh
exit 0;
|
Windows系統:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 30px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
|
@echo off
exit 0
|
5.9 調整配置:其他選項
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[svn]
...
minimalRevision = 1024
|
設定subversion版本的svn.minimalRevision值來指定從哪裡開始轉換。修訂比指定的老蔣不會轉換,將不存在於git庫。通過該選項來限制修訂範圍可以減少轉換時間。
5.10 執行subgit安裝
執行subgit安裝命令使subgit開始從subversion轉換到git,同時啟動之前產生的配置命令synchronization.install。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 135px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
|
subgit install repository.git
SubGit version 2.0.0 ('Patrick') build #2552
Translating Subversion revisions to Git commits...
Subversion revisions translated: 20.
Total time: 10 seconds.
INSTALLATION SUCCESSFUL
|
最初的轉換需要一段時間,在這段時間git庫是可讀的,但是,推是禁用的。
subgit安裝命令啟動同步安裝鉤子到git庫。已存在的git pre-receive和post-receive鉤子將保留並正常執行。
Repository after install command is completed:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 210px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
GIT_REPOS/
branches/
hooks/
pre-receive # SubGit hook, do not edit or remove
user-pre-receive.sample # user's pre-receive hook template
post-receive # SubGit hook, do not edit or remove
user-post-receive.sample # user's post-receive hook template
logs/
objects/
refs/
svn/
subgit/
config
HEAD
|
一旦安裝命令報告成功終止,git使用者就可以推程式碼到git庫。新的提交將被轉換到新的subversion版本庫修訂,反之亦然,新的subversion修訂將被轉換到新的git提交。
5.11 後臺執行轉換
一旦安裝完成後,subgit啟動後臺程式,定期拉取subversion版本庫。每當新的修訂被發現,將轉換為git提交。這樣,git庫在大部分時間保持最新。這個後臺程式是可選的,可以被killed。當後臺程式沒有執行時,新的subversion修訂將通過git使用者推pre-receive鉤子來處理。除非在配置檔案中禁用,使用者推將重啟啟動後臺轉換程式。
配置GIT_REPOS/subgit/config檔案來定義subgit程式:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 105px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
|
[svn]
...
fetchInterval = 60 # check for new revisions every 60 seconds
...
[daemon]
...
idleTimeout = infinity # backgroud process never exits
|
設定daemon.idleTimeout選項為0,後臺轉換程式可能會被禁用。在這種情況下,推完成,轉換程式立即退出:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[daemon]
...
idleTimeout = 0 # backgroud process disabled
|
強制轉換未完成的subversion修訂,可以通過下面命令:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
subgit fetch [--async] GIT_REPOS_PATH
|
或者呼叫從遠端工作樹no-op推:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 15px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
|
git push origin +:refs/heads/bogus_branch
|
上面的命令將嘗試刪除不存在的遠端分支和強制subgit同步git與subversion庫。
優雅關閉後臺程式命令:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 120px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
|
subgit shutdown repository.git
SubGit version 2.0.0 ('Patrick') build #7777
About to shut down background translation process.
Shutdown request sent to background translation process (pid 4404).
Background translation process has received shutdown request and will exit NOW.
SHUTDOWN SUCCESSFUL
|
5.12 推薦的git客戶端配置
git使用者將從伺服器上克隆git庫到本地。有一些配置選項建議新增到.git/config配置檔案中。雖說不是必須的,但是會帶來更好的使用者體驗。
Fetch SubGit mapping information:
[remote "origin"]
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[remote "origin"]
...
fetch = +refs/svn/map:refs/notes/commits
|
refs/notes/commmits包含每個提交到git的對映資訊。有了這些記錄,git log命令將展示對映資訊和提交資訊:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 135px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
|
git log
commit bee5c8ae9bd8b2077f1acaedc9982ab4bd84d91b
Author: Alexander Kitaev kitaev@tmatesoft.com
Date: Thu Sep 6 18:58:01 2012 +0200
Ugly bug fixed
Notes:
r1 trunk
|
Fetch all tags:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
[remote "origin"]
...
tagopts = '--tags'
|
--tags選項將強制git獲取所有的標籤,即使從當前分支不可取得。
六. 更改subgit配置
6.1 Writing Hooks
為了使subversion和git同步,subgit安裝鉤子到git庫。這些鉤子是:
1. Git pre-receive hook
2. Git post-receive hook
這些鉤子對於subgit正常工作至關重要的,使用者不應該修改或刪除這些鉤子指令碼。如有必要,上面這些鉤子應該放置到user-在適當的時候。subgit安裝命令在意以存在的鉤子,並自動將其內容寫入到相應的user-指令碼中。
下表顯示了標準的鉤子指令碼檔案和subgit安裝後的檔名對應關係。subgit不會影響鉤子的引數和返回程式碼規則。未在表中列出的鉤子不會被subgit使用,標準的檔名稱不會改變。
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 45px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
|
standard hook name hook name after SubGit is installed
pre-receive user-pre-receive
post-receive user-post-receive
|
在windows系統下,subversion鉤子檔案是以.cmd或.bat作為副檔名的。
6.2 應用配置更改
subgit安裝到庫後,subgit配置可以更改。一些改變將會立即生效,其他需要安裝subgit,重建要執行的命令,使應用更改。
更改立即生效場景:
1. 修改作者對映檔案subgit/authors.txt
2. 修改密碼憑證檔案subgit/passwd
3. 修改或建立user-*鉤子指令碼
執行'subgit install'命令後更改才生效場景:
1. 修改subgit/config檔案的core.authorsFile選項
2. 修改subgit/config檔案的svn.fetchInterval選項
3. 修改subgit/config檔案的[auth]部分
subgit install命令將驗證subgit/config所做的更改,並將這些更改應用。 如果需要的話,重新啟動後臺轉換程式。
其他配置更改:尤其是更改subgit/config檔案的branches對映,最簡單的方法是安裝標準配置階段重新安裝subgit。在以安裝subgit下,更改branches不可能對映到git庫。停止後臺轉換程式,在git庫上執行subgit uninstall命令。
七. 解除安裝subgit
執行subgit uninstall命令禁止同步或解除安裝subgit。
執行uninstall未帶選項將刪除subgit鉤子,從而停止轉換:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 195px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
subgit uninstall repository.git
SubGit version 2.0.0 ('Patrick') build #7777
About to shut down background translation process.
Shutdown request sent to background translation process (pid 4900).
Background translation process has received shutdown request and will exit NOW.
SHUTDOWN SUCCESSFUL
SubGit hooks have been removed from Git repository:
/var/git/repository.git
Subversion and Git are no longer kept in sync.
|
在執行subgit uninstall帶上--purge選項,將完全刪除subgit。--purge將刪除:
1. subgit二進位制和日誌檔案
2. subgit後設資料
八. 註冊subgit
注不註冊隨你所好。
九. 轉換侷限性
subversion和git版本控制系統解決了同樣了問題,那就是為什麼subversion和git程式碼庫同步是可能的。然而,subversion和git實現不同,因此兩者有些實體是沒法轉換的。
下面的實體沒法從subversion轉換到git:
1. 任意使用者定義的屬性
2. 版本屬性
3. svn:externals屬性
4. 空目錄
5. 鎖檔案
6. cherry-pick合併跟蹤資訊
7. subversion基於路徑驗證
下面的實體沒法從git轉換到subversion:
1. git子模組
2. git筆記
3. 不相關的檔案屬性
subgit未來版本或許將刪除上述限制。
十. 備份
subgit2.0版本不提供整合的備份解決方案。標準的git工具可以用來備份庫。
備份git庫:
首先,禁止git推,然後禁止subgit同步:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 90px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
|
make user-pre-receive hook reject all pushes:
cp /var/git/repos.git/hooks/user-pre-receive /var/git/repos.git/hooks/user-pre-receive.backup
echo '#!/bin/sh\nexit 1' > /var/svn/repos/.git/hooks/user-pre-receive
disable synchronization
subgit uninstall /var/git/repos.git
|
uninstall命令將等待未完成的轉換,然後關閉轉換後臺程式。執行jps命令確保它沒有在執行,檢查是否有SubGitDaemon java程式。然後,備份一切資料,重新安裝subgit、啟動同步和git推:
<textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly="" style="box-sizing: border-box; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 12px !important; font-family: Monaco, MonacoRegular, "Courier New", monospace !important; color: rgb(0, 0, 0); line-height: 15px !important; background: rgb(255, 255, 255); width: 699.391px; overflow: hidden; padding: 0px 5px; margin: 0px; height: 135px; position: absolute; opacity: 0; border: 0px; border-radius: 0px; box-shadow: none; white-space: pre; word-wrap: normal; resize: none; tab-size: 4; z-index: 0;"></textarea>
|
1
2
3
4
5
6
7
8
9
|
back up all data
copy -R /var/git/repos.git repos.git.backup
enable synchronization
subgit install /var/git/repos.git
make user-pre-receive hook no longer reject pushes
rm /var/git/repos.git/hooks/user-pre-receive
cp /var/git/repos.git/hooks/user-pre-receive.backup /var/git/repos.git/hooks/user-pre-receive
|
十一. 系統需求
subgit可以執行在大部分系統上,要求如下:
1. Windows XP or newer, Linux or OS X
-
Oracle Java 1.5 or newer
3. 至少256MB*K可用記憶體,K是subversion版本庫的數量
subgit2.0鉤子指令碼使用本地預編譯的可執行檔案,因此每個推啟動JVM沒有開銷。有些系統可能無法執行預編譯二進位制,subgit將回落到基於java的鉤子。在這種情況下,記憶體需要以32Mb*N倍數增加,N是推的最大併發數。
可用記憶體包括實體記憶體和swap分割槽,在subgit高峰時,最好能多分配寫記憶體。
十二. 安裝subgit工具
下載相關係統平臺安裝包:http://subgit.com/download/
如需轉載請註明出處:SubGit中文手冊:獲取一個遠端subversion庫映象 http://www.ttlsa.com/html/1906.html
相關文章
- 【Linux Ops】如何無痛升級 glibcLinux
- svn 遷移到gitGit
- Linux CentOS升級安裝gitLinuxCentOSGit
- git 如何 實現 svn那樣對某個檔案的許可權?Git
- CentOS7 升級 Git 歷程CentOSGit
- 痛!痛!痛!我們的好兄弟Git,一路走好!Git
- Git和SVN的對比Git
- git和SVN的區別?Git
- svn和git的區別Git
- Java升級那麼快,多個版本如何靈活切換和管理?Java
- 升級struts2-2.5,其實並沒有想象中的那麼難
- 升級mac Mojave系統,git無法使用MacGit
- MacOs 升級 Git 到最新版本MacGit
- mysql怎麼升級MySql
- SVN管理是什麼?SVN安裝教程,SVN可以做什麼
- svn和git版本管理優缺點Git
- git與svn的區別面試Git面試
- 02 SVN 與 Git 的優缺點Git
- macOS 11.0怎麼升級?macOS Big Sur 升級教程Mac
- 教你如何在CentOS中自行編譯升級GitCentOS編譯Git
- 關於git 和 svn 的協調使用(主要用於方便在git 和 svn之間管理程式碼)Git
- 版本管理工具之Git 和SVNGit
- 『現學現忘』Git基礎 — 2、Git和SVN的區別Git
- 阿里雲伺服器怎麼升級配置?升級有哪些限制?阿里伺服器
- win10升級11102升級失敗怎麼辦_win10升級11102升級一直失敗修復方法Win10
- 軟體測試:SVN與Git的差異Git
- GoCN每日新聞(2018-09-11)Go
- Win10怎麼升級版本 Win10升級版本的方法Win10
- 為什麼SAP ECC系統需要升級?升級路徑有哪些?
- Nacos 爆重大 Bug!!不要升級,不要升級,不要升級
- Mac升級至macOS High Sierra後導致git無法使用MacGit
- 對比Git 與 SVN,這篇講的很易懂Git
- 如何從SVN遷移原始碼到Git倉庫原始碼Git
- 程式碼伺服器(SVN/GIT)防洩密(一)伺服器Git
- SVN/Git程式碼伺服器防洩密(二)Git伺服器
- iOS11.4.1beta4升級攻略 iOS11.4.1beta4怎麼升級iOS
- iOS11.4.1beta3升級攻略 iOS11.4.1beta3怎麼升級iOS
- iOS11.4.1beta5升級攻略 iOS11.4.1beta5怎麼升級iOS