Request to keep submission records on SVN
1. Account correspondence
- SVN's log records:
r2 | lisi | 2014-12-12 15:11:59 +0800 (五, 12 12月 2014) | 1 line
ssss
- git log records:
Author: zhangsan <[email protected]>
Date: Thu Jan 16 11:28:30 2020 +0800
初始化意见反馈模块
commit 938ef83245f699c5c016b98ce454cffba3ce8eff
Comparing the log records of svn and git, it can be found that svn only uses the account to display the submission record, and git not only uses the account, but also uses the mailbox to confirm. So svn migration to git, you need to convert the two accordingly.
The method is to export the svn account, and then convert the svn account to the svn account on the left side of the equal sign, and the GitLab account and mailbox information on the right side of the equal sign. zhangsan=zhangsan <[email protected]>
Such information is recorded in a file. One line. Because we only focus on the log information, we only export the accounts in the log records and operate on these accounts. The following command completes the export of account correspondence:
svn log SVN项目的url -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2"="$2" <"$2"@example.com>"}' | sort -u > 记录账号对应关系的文件路径
Below we export the account correspondence to the file svn2git.txt:
~/Desktop$ svn log http://10.69.10.15:8080/svn/ai_project | awk -F '|' '/^r/ { sub(" ","",$2); sub(" $","",$2); print $2"="$2" <"$2"@example.com>"}' | sort -u > svn2gitlab.txt
Command explanation:
- http://10.69.10.15:8080/svn/ai_project: export svn logs
- The exported logs will be passed to the awk command through the pipeline '|'
- The processing unit of awk is one line, so awk divides each line of data by "|", and the second item of the result is the account name. Sub removes the space and $ symbol from the account name, and finally outputs the account number. The account number is passed to the sort command through the pipeline "|" for de-reordering, and finally the result is saved to the file svn2gitlab.txt
2.git-svn pull SVN project
Use git-svn to pull the SVN project.
-
Download and install git-svn, you can search for git-svn at http://fr2.rpmfind.net/linux/rpm2html/search.php , and then choose to download and install according to your platform. Of course, you can also use the source to install, such as ubuntu can use: sudo apt-get install git-svn
-
Execute the command:,
git svn clone "SVN项目url" --no-metadata --authors-file="账号对应关系文件" 自定义项目名
pull the project, and use the account correspondence file to convert the svn submission record into a git submission record.Normal svn checkout:
~/Desktop/H/ai_project$ ls -a . app gradle local.properties key.sign proguard-project.txt .svn .. build.gradle .gradle main.iml pda_svn.iml settings.gradle
Use git svn to pull:
~/Desktop/TestSVN2Git/ai_project$ ls -a . app .git .gradle main.iml pda_svn.iml settings.gradle .. build.gradle gradle local.properties key.sign proguard-project.txt
As can be seen from the comparison above, it
.svn
is converted into.git
,
Examples:
~/Desktop/TestSVN2Git$ git svn clone http://10.69.10.15:8080/svn/ai_project --no-metadata --authors-file=../svn2gitlab.txt ai_project
3. Submit the project to GitLab
Switch to the project directory pulled with Git-svn:
- Configure project user information
git config --local user.name "GitLab用户名"
git config --local user.email "GitLab邮箱"
Such as:
~/Desktop/TestSVN2Git/ai_project$ git config --local user.name "Administrator"
~/Desktop/TestSVN2Git/ai_project$ git config --local user.email "[email protected]"
-
Create on the GitLab web page or use the GitLab API to create an empty warehouse, refer to "Migrate from local git warehouse to remote git warehouse"
Finally, get the git address of the empty warehouse: http://10.69.10.13/android/aiproject.git
-
Associate local warehouse to new remote warehouse
git remote add origin GitLab项目的git地址
~/Desktop/TestSVN2Git/ai_project$ git remote add origin http://10.69.10.13/android/aiproject.git
-
Push remote
git push -u origin master
~/Desktop/TestSVN2Git/ai_project$ git push -u origin master
At the third step, the completion is the problem of migrating the local git repository to the remote git repository .
postscript:
When svn migrates git, it is roughly that git svn uses the account correspondence file to pull the svn submission record into a git submission record when pulling the project, and then push it to the new project.