為了統(tǒng)一、規(guī)范開發(fā)流程,以及CICD的推進(jìn),將SVN整體遷移至git環(huán)境,需要將歷史記錄同步到git
本文參考了以下鏈接
https://blog.csdn.net/ouyang_peng/article/details/80372805
https://www.cnblogs.com/goodwell21/p/10044818.html
主要分三步
1.svn用戶映射
到svn工程目錄下執(zhí)行命令
svn log --xml | grep "^<author" | sort -u | \awk -F '<author>' '{print 1}' > userinfo.txt
獲取當(dāng)前項(xiàng)目的用戶,然后每一天修改為以下格式
malone=malone< malone@123.cc>
新建個(gè)文件夾,把userinfo.txt拷貝過來(項(xiàng)目過多的話此過程不需要重復(fù)完成,執(zhí)行一遍后,將所有用戶名稱都寫到此txt中可重復(fù)利用
)
2.git svn clone
在上userinfo.txt目錄執(zhí)行命令
git svn clone http://malone@svn.test.cc:8011/svn/sdk_dev/iOS/AutoTest-iOS GitProject --authors-file=userinfo.txt --no-metadata(svn copy URL獲取地址)
等待執(zhí)行完成后,進(jìn)入GitProject目錄,執(zhí)行g(shù)it log 確定git成功
3.push到git
先在git/gitlab新建項(xiàng)目
git remote add origin git@gitlab.1223.com:sdk/autotest-ios.git
git remote -v(執(zhí)行確定添加成功)
git push origin --all (執(zhí)行成功后到git/gitlab頁面刷新看看是否成功,查看歷史頁面是否同步成功)
錯(cuò)誤:
1.執(zhí)行g(shù)it push origin --all 時(shí)出現(xiàn)錯(cuò)誤
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
解決辦法: 先執(zhí)行g(shù)it remote add origin git@gitlab.1223.com:sdk/autotest-ios.git命令
2.Author: ** not defined in users.txt file
1)是由于userinfo.txt文件格式有誤,應(yīng)該為 malone= malone < malone@tests.cc>
2)是userinfo.txt真的少了該用戶的配置(修改后記得刪除git的目錄 再執(zhí)行命令)