LoginSignup
9
8

More than 5 years have passed since last update.

git-svnで(trunkとかbranchとかのない)SVNからGitに移行

Posted at

メモ

目的

SVN管理していた、いにしえのプロジェクトレポジトリをgitに移行したい

手順

参考下記
http://qiita.com/hidekuro/items/4727715fbda8f10b6b11

まず試す

■cloneコマンド
git svn clone -s --prefix=svn/ https://your.svn/repos/project
■init => fetchコマンド
git svn init -s --prefix=svn/ https://your.svn/repos/project
git svn fetch

→これでうまくいかない場合

svnの使い方もそこまで詳しくないですが、普通はルートディレクトリに/trunkとか/brunchってディレクトリがあって、それをgitにも反映してくれるっぽい。
ただ、そういう使い方をそもそもせずtrunkディレクトリ等が存在しない場合、上記コマンドだと"Initialized empty Git repository"と表示された後なにもadd されずに空のgitレポジトリができる。そういうときは
--trunkオプションでtrunkをルートディレクトリに指定する

git svn clone --trunk=/ http://hogehoge.com/svn/hoge_repository

うまくいくとSVNレポジトリがmasterブランチにcloneされる。その他--branchオプションなどもあるようなので必要なら使うといいかも

確認

yama@test $ git branch -a
* master
  remotes/origin/trunk
yama@test $ git svn info
Path: .
URL: http://hogehoge.com/svn/hoge_repository
Repository Root: http://hogehoge.com/svn/hoge_repository
Repository UUID: 7C43DC2B-C610-4F65-8628-6B6DCB8BB1CB
Revision: 1234
Node Kind: directory
Schedule: normal
Last Changed Author: hoge
Last Changed Rev: 1233
Last Changed Date: 201x-xx-xx 09:17:30 +0900 (月, xx xx 20xx)

上記のようにブランチ・元のsvnレポジトリ情報は残る。

元のレポジトリ情報削除

移行したらむしろ元のsvnレポジトリは消したいので、リモート情報も一緒に消したかった。
branchは消し方分かったけど、svnレポジトリの情報の消し方分からないので知ってる方いたらご教授願いたいです…

yama@test$ git branch -rD origin/trunk #-rでリモート、-Dで強制削除
Deleted remote branch origin/trunk (was 098f6bc).

以上

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8