IT, 筆記

Migrate SVN Local repo to Git repo

背景

十多年前我是用SVN來儲存資料,不需要SERVER就可以把整個REPOSITORY ZIP起來。到現在,SVN不及GIT進步了,所以今天我打算著手把SVN轉移到自家在NAS的GITEA。

準備SVN Repository

先從備份ZIP解壓到臨時目錄,例如 D:\temp\my-svn-project1. Repository 目錄應該有 conf, db, hooks, locks, 等子目錄。

WSL2

為了之後方便操作所以會轉到WSL2下面,不會用 Windows Prompt/Powershell。

在WSL2中,上文Repository 目錄的相對位置為:/mnt/d/temp/my-svn-project1

轉換成 git repository

目前找到有2個工具可以轉移 SVN 到 GIT - Git-svn和 SubGit。目前試過Git-svn成功所以下面內容是基於Git-svn。

執行 git svn clone

首先要把 svn 轉換成本地 git repository,我們可以用 git svn clone 指令,這個例子中 /mnt/d/temp/my-git-project1 為輸出目錄:

git svn clone file:///mnt/d/temp/my-svn-project1 /mnt/d/temp/my-git-project1

目前我只需要用最簡單的方法,不用顧及 authors,layout等等

在 Git 服務(Gitea)建立對應的 Git Repository

在Gitea中new Repository,然後記下URL, 例如:https://git.badbuta.com/badbuta/myproject1.git

新增remote origin

進入本地 git repository,如 /mnt/d/temp/my-git-project1 ,輸入指令

git remote add origin https://<token>@git.badbuta.com/badbuta/myproject1.git
git push --all origin
git push --tags origin

回到 Git 服務(Gitea)檢查

檢查剛建立的Git Repository,資料應該成功轉移。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *