代码改变世界

convert svn repo to git

2019-07-09 18:16  divl  阅读(343)  评论(0编辑  收藏  举报
https://john.albin.net/git/convert-subversion-to-git


1. 抓取Log 在linux 上做的,其余是在win上做的。

2. svn co svn://192.168.1.198/projects/ios --username xx

3. 抓取Log 信息
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt

4. checkout 
git svn clone svn://192.168.1.198/projects/ios --username xx --no-metadata -A authors-transform.txt --stdlayout ~/temp


5. 新建git repo
git init --bare ~/new-bare.git
cd ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk

6. push
cd ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

7. rename branch
cd ~/new-bare.git
git branch -m trunk master