svnからgitに切り替えるのはなかなかに大変というか、踏ん切りが付かないもので
gitで出来る事はsvnでも出来ちゃったりする事もあるので「svnのままでもいいじゃん」ってのがあります。
だけども新しいものを使いたいし、ちゃんとgitを使いこなし、branchを使いこなして開発を行いたいものであります。
少しずつでもいいからsvnからgitに移行できるようにsvnリポジトリでの変更があったら、gitリポジトリにも変更が反映させるというhookスクリプトを設置しておいて、いつでもgitリポジトリが最新になっていて、「gitリポジトリがあるんならこっち使っちゃえば良いじゃん」ってなれば良いなと妄想して調べてみた物がこちら。
git svn clone --prefix svn/ -s <svn_url> <git_path>
cd <git_path>
for branch in $(svn ls <svn_url>);
do
git branch ${branch} remotes/svn/${branch}
done;
cd <git_path>
vi .git/hooks/svn-rebase-all
# !/bin/sh
git=/usr/local/bin/git
date >> .git/svn-rebase.log
${git} reset --quiet --hard
for ref in .git/refs/heads/*
do
branch=${ref##*/}
echo Updating ${branch}
${git} checkout --quiet --force ${branch}
${git} svn rebase
done 2>&1 | tee -a .git/svn-rebase.log
${git} checkout --quiet --force master
chmod +x .git/hooks/svn-rebase-all
cd <svn_path>/
vi hooks/post-commit
# !/bin/sh
cd <git_path>
. .git/hooks/svn-rebase-all
chmod +x <svn_path>/hooks/post-commit
参考 : [svn - Automatically synchronizing a Subversion repository and a Git repository - Stack Overflow] (http://stackoverflow.com/questions/5586993/automatically-synchronizing-a-subversion-repository-and-a-git-repository)
あらかじめsvnのリポジトリサーバーでgit svn clone
をしておいて、gitのhookスクリプトにsvnの変更を取り込むスクリプトを置いておいて、svnでコミットがあった時にそのスクリプトを実行させるというものです。
gitでcloneしたローカルの方でbranchesのbranch切っておいてください。(なんかややこしいな)
svnの変更をgitのリポジトリに取り込んだので、後はgithubにpushするなり、取り込んだリポジトリをcloneするなりしてくればよしです。
参考リンクの方にはpushした時にdcommitしてくれるスクリプトもあるみたいだけど、そこまではまだ大丈夫かなー