新聞中心
隨著項目越來越大,原有SVN已經很難支撐現(xiàn)有工程(集中式管理,服務器壓力大,分支主干切換麻煩)。所以,決定將SVN切換成Git(分布式開發(fā),快照式數據,速度快,主干分支切換方便),下面為大家分享一下Linux下SVN遷移至Git具體方法。

10年積累的網站設計、成都做網站經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站制作后付款的網站建設流程,更有蓬溪免費網站建設讓你可以放心的選擇與我們合作。
1.物理環(huán)境
Git–server Centos5.8 192.168.1.245
Svn–server Centos5.8 192.168.1.108
2.建立SVN用戶到git用戶的映射文件
建立SVN用戶到git用戶的映射文件,文件格式如下:
cat /tmp/userinfo.txt
david=sfzhang
yanni=yanni
3.克隆一個git版本庫
通過git svn clone克隆一個git版本庫,SVN里面包含trunk,branches和tags。
git svn clone svn://192.168.1.108:9999/yanzi/ --no-metadata --authors-file=userinfo.txt --trunk=trunkmobile --tags=tags --branches=branches --ignore-refs=refs/remotes/yanzi-.* yanzi
參數–no-metadata表示:阻止git導出SVN包含的一些無用信息 參數–authors-file表示:SVN賬號映射到git賬號文件,所有svn作者都要做映射 參數–trunkmobile表示:主開發(fā)項目 參數–branches表示:分支項目,–ignore-refs表示不包含后面的分支項目 參數yanzi表示:git項目名稱
4.查看項目提交的歷史記錄
通過git log 查看項目提交的歷史記錄,包括作者,日照,和提交注釋信息等。
cd yanzi
git log
commit 3c4907782804096ea3fa3fb5419dcce610e56f1f
Author: david
Date: Fri May 10 10:27:50 2013 +0000
5.列出當前所有的分支
cd yanzi
git branch -r
tags/mobile_1.0.0
tags/mobile_1.0.1
trunk
yanziios1.0.1-build-2223-branch-002
6.手動將branches分支轉換為tags
git tag mobile_1.0.0 tags/mobile_1.0.0
git tag mobile_1.0.1 tags/mobile_1.0.1
7.將多余的branches刪除掉
git branch -r -d tags/mobile_1.0.0
Deleted remote branch tags/mobile_1.0.0 (was d50002b).
git branch -r -d tags/mobile_1.0.1
Deleted remote branch tags/mobile_1.0.1 (was e7b78a2).
8.再次列出當前的所有分支
git branch -r
trunk
yanziios1.0.1-build-2223-branch-002
9.建立git倉庫并初始化版本庫
mkdir -p /data/gitdata/yanziios.git
cd /data/gitdata/yanziios.git/
git init --bare
Initialized empty Git repository in /data/gitdata/yanziios.git/
10.將yanziios.git的屬主修改為git用戶
chown git yanziios.git -R
ls -l yanziios.git/
total 64
drwxr-xr-x 2 git root 4096 May 22 12:25 branches
-rw-r--r-- 1 git root 66 May 22 12:25 config
-rw-r--r-- 1 git root 73 May 22 12:25 description
-rw-r--r-- 1 git root 23 May 22 12:25 HEAD
drwxr-xr-x 2 git root 4096 May 22 12:25 hooks
drwxr-xr-x 2 git root 4096 May 22 12:25 info
drwxr-xr-x 4 git root 4096 May 22 12:25 objects
drwxr-xr-x 4 git root 4096 May 22 12:25 refs
11.添加遠程git服務器地址
git remote add origin [email protected]:/data/gitdata/yanziios.git
12.推送全部的分支和標簽信息到git服務器上
git push origin master --tags
之后就是SVN遷移到Git測試,在客戶端用SourceTree工具克隆一個Git服務端倉庫yanziios.git,在SourceTree圖形界面里面可以看到git用戶提交的Graph信息,描述信息(Description),日期,作者和版本號等信息。
文章題目:Linux下SVN遷移至Git具體方法
標題來源:http://m.fisionsoft.com.cn/article/dhsscdo.html


咨詢
建站咨詢
