參考:GIt - 遷移到Git
構(gòu)建user.txt
關(guān)聯(lián)svn用戶和git用戶。
svn log ^/ --xml | grep -P "^<author" | sort -u | \
perl -pe 's/<author>(.*?)<\/author>/$1 = /' > users.txt
用git svn導(dǎo)入svn庫
如果svn庫不是標(biāo)準(zhǔn)的trunk/branches/tag目錄結(jié)構(gòu),則需要手動指定對應(yīng)的trunk/branches/tag。如果branches目錄包含了多個項目的分支,可以把指定項目的所有分支切到新的branches目錄中。
git svn clone http://my-project.googlecode.com/svn/ \
--authors-file=users.txt --no-metadata -s my_project
創(chuàng)建本地分支
git for-each-ref refs/remotes | cut -d / -f 3- | grep -v @ | while read branchname; do git branch "$branchname" "refs/remotes/$branchname"; git branch -r -d "$branchname"; done
提交到遠(yuǎn)程
git remote add origin ssh://git@my-git-server:myrepository.git
git push origin --all