SVN 迁移到 Git 实操步骤

2018-03-15  本文已影响6人  custa
git@my-git-server:myrepository.git
svn log --xml | grep author | sort -u | perl -pe 's/.*>(.*?)<.*/$1 = /' >users.txt

编辑 users.txt,映射 Git 用户数据,格式为

username = username <email>
git svn clone --authors-file=users.txt --no-metadata --stdlayout --prefix="" http://my-project.googlecode.com/svn/ my_project
for p in $( git for-each-ref --format='%(refname:short)' | grep "@" ); do
    git branch -D -r $p
done
for t in $( git for-each-ref --format='%(refname:short)' refs/remotes/tags ); do
    git tag ${t/tags\//} $t
    git branch -D -r $t
done
for b in $( git for-each-ref --format='%(refname:short)' refs/remotes ); do
    git branch $b refs/remotes/$b
    git branch -D -r $b
done
git branch -d trunk
git remote add origin git@my-git-server:myrepository.git
git push origin --all
git push origin --tags

参考:
https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git

上一篇下一篇

猜你喜欢

热点阅读