[Git] SVN から Git へ移行する

もろもろ試してみました。

[markdown]

## リポジトリを引き継ぐ

一般的にはリポジトリを引き継ぐことが多いと思います。
どんな方法があるのか。

### git svn

> * [SubversionのリポジトリをGitリポジトリに移行する – どっかのBlogの前身のような](http://parrot.hatenadiary.jp/entry/20111025/1319519285)

### svn2git

> * [個人的な svn リポジトリを bitbucket に移した | T.T.Soft Code Blog](http://code.ttsoft.jp/2013/01/private-svn-repository-move-to-bitbucket.html)

### Bitbucket

機能があるよう。

Bitbucket 2013-08-16

## Bitbucket インポーター

もろもろ分からずあきらめました。

[Bitbucket](https://bitbucket.org/)

### Site

できませんでした。
ローカルの場合は、どう指定するんでしょうか?

Bitbucket 2013-08-16 13-41-12

### SourceTree

途中でエラーが出て止まってしまいました。

Bitbucket 2013-08-16 13-49-28

## git svn を使う

> * [[git] Subversionからgitへ移行する – wadslog](http://wadslab.net/2008/07/subversion-git/)
> * [svn の repository を git の repository に変換する方法 | 株式会社メッサリバティ](http://jp.messaliberty.com/2009/12/how-to-convert-svn-repo-to-git-repo/)

“`
% git svn clone file:///Users/***/svn/svn2git svn2git_new
Initialized empty Git repository in /Users/***/projects/svn2git_new/.git/
A tests/application/controllers/IndexControllerTest.php
A tests/bootstrap.php
A tests/phpunit.xml
A .zfproject.xml
A application/Bootstrap.php
A application/controllers/IndexController.php
A application/controllers/ErrorController.php
A application/configs/application.ini
A application/views/scripts/index/index.phtml
A application/views/scripts/error/error.phtml
A docs/README.txt
A public/.htaccess
A public/index.php
W: +empty_dir: application/models
W: +empty_dir: application/views/helpers
W: +empty_dir: library
W: +empty_dir: tests/library
r1 = 9fafce44d07d1b9793f809d4c28d625449333056 (refs/remotes/git-svn)
A docs/add.txt
r2 = 3d7b108e55818610f3e51e75963984d2e2a4bca6 (refs/remotes/git-svn)
Checked out HEAD:
file:///Users/***/svn/svn2git r2
creating empty directory: application/models
creating empty directory: application/views/helpers
creating empty directory: library
creating empty directory: tests/library
“`

引き継げているようです。

“`
% git log
commit 3d7b108e55818610f3e51e75963984d2e2a4bca6
Author: *** <***@b14cf2f6-1541-407f-a031-d034b2552f5d>
Date: Fri Aug 16 01:53:30 2013 +0000
add add.txt
git-svn-id: file:///Users/***/svn/svn2git@2 b14cf2f6-1541-407f-a031-d034b2
commit 9fafce44d07d1b9793f809d4c28d625449333056
Author: *** <***@b14cf2f6-1541-407f-a031-d034b2552f5d>
Date: Fri Aug 16 01:35:39 2013 +0000
initial import
git-svn-id: file:///Users/***/svn/svn2git@1 b14cf2f6-1541-407f-a031-d034b2
“`

## 関連ディレクトリの削除

リポジトリを引き継ぐ必要がなければ、削除して git init すれば良いですね。
下記の方法でディレクトリを作ったとして後述のとおり。

> * [Subversion の使い方 | deadwood](https://www.d-wood.com/blog/2013/08/16_4502.html#more-4502)

### .svn ディレクトリを削除

プロジェクトディレクトリへ移動。.svn を探す。
(2つの方法をメモ)

“`
% find ./ -name “.svn”
“`

“`
$ find.-typed-name.svn
“`

.svn を削除する。

“`
% find ./ -name “.svn” | xargs rm -R
“`

“`
$ find.-typed-name.svn-print0|xargs-0 rm-rf
“`

> * [Mac – Subversionの「.svn」ディレクトリを全部削除する – Qiita [キータ]](http://qiita.com/odorry/items/14f707594666840a42d7)

### リポジトリを削除

~/svn にあるレポジトリを削除する。

“`
% rm -rf ~/svn
“`

## 補遺

政治的理由で Subversion つかうこともあるかなぁ。

> * [SubversionからGitへ移行するときの問題について簡単に語る – SSSSLIDE](http://sssslide.com/speakerdeck.com/ogawa/subversiongit)

[/markdown]