Skip to content

Instantly share code, notes, and snippets.

@numa08
Created March 20, 2014 03:00
Show Gist options
  • Save numa08/9656343 to your computer and use it in GitHub Desktop.
Save numa08/9656343 to your computer and use it in GitHub Desktop.
人間git-svnとして生きる

SubversionとGit中央リポジトリのコードを綺麗に取得する方法

git中央リポジトリとSubversionリポジトリの両方にpush(commit)する必要があるケースを想定。

既にgit中央リポジトリとSubversionリポジトリに何度かcommit(push)が実施されているコードを取得する場合、単純にgit svn cloneを行うと、gitのログと異なるハッシュでログが生成されてしまう。

それを防ぐにはgit clone後にSubversionの情報を取得する必要がある。

git clone ${git central repository} ${dir name}
cd ${dir name}

次にSubversionの情報を登録

git svn init ${SVN URL}

最新コミットのハッシュを合わせる

git show origin/master | head -n 1 | awk '{print $2}' > .git/refs/remotes/git-svn

Subversionリポジトリのログを取得

git svn fetch

注意するべきはSubversionのURLとrefs/remotes/以下のファイルの名前だろう。このURLとファイル名はどうも最初にSubversionにコミットを行った設定を引き継がなければならないらしい。

この辺りに闇を感じる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment