SVN工程转Git工程&Github托管
- 1. 介绍
- 2. autoAudioTest之SVN转Github步骤
- Step 1 工作环境(ubuntu)
- Step 2 安装升级必要软件
- Step 3 转换脚本
- Step 4 检查软件运行环境
- Step 5 生成authors.txt
- Step 6 SVN转换Git格式
- Step 7 Github新建空工程
- Step 8 Git提交已有工程
- Step 9 Git提交经转换的SVN工程
- Step 10 解决GH001: Large files detected
- Step 11 Git再次提交经转换的SVN工程
- Step 12 Github刷新工程
- 3. autoAudioTest之单循环测试视频
- 4. autoAudioTest手册&版本
- 5. 参考资料
1. 介绍
鉴于很多项目以前是使用SVN进行管理的,最近打算逐步将一些代码开源出来,以便需要的朋友使用。这就不可避免的出现了SVN代码如何转到Github上的问题。
主要的问题是希望之前的上传记录不要丢失,这里结合一个例子正好整理和测试下命令是否可以正常的将SVN代码转到Github进行托管。
2. autoAudioTest之SVN转Github步骤
Step 1 工作环境(ubuntu)
$ uname -a
Linux daniel-ThinkPad-SL410 5.15.0-58-generic #64~20.04.1-Ubuntu SMP Fri Jan 6 16:42:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
Step 2 安装升级必要软件
这里可能涉及一些工作环境之前已经预装的软件,比如:java等
注:下面这些软件是必须的,就特地强调一下。
$ mkdir GitMigration
$ cd GitMigration
$ sudo apt-get install subversion git git-svn
Step 3 转换脚本
Download svn-migration-scripts.jar
$ wget https://bitbucket.org/atlassian/svn-migration-scripts/downloads/svn-migration-scripts.jar
注:感觉这个并不重要,因为实际对工程项目了解的话,看下日志记录,可以自己写那个author.txt文档。
Step 4 检查软件运行环境
$ java -jar svn-migration-scripts.jar verify
svn-migration-scripts: using version 0.1.56bbc7f
Git: using version 2.25.1
Subversion: using version 1.13.0
git-svn: using version 2.25.1
Step 5 生成authors.txt
主要目的是为了导出并修改后续github中每个commit的作者名字及联系方式
$ java -jar svn-migration-scripts.jar authors svn://192.168.68.200/BloodDiamond-Echo > authors.txt
$ cat authors.txt
lida = lida <lida@mycompany.com>
root = root <root@mycompany.com>
修改为如下格式:
$ vi authors.txt
$ cat authors.txt
lida = lida <lida-mail@163.com>
root = root <lida_mail@163.com>
Step 6 SVN转换Git格式
$ git svn clone --stdlayout --authors-file=./authors.txt svn://192.168.68.200/BloodDiamond-Echo autoAudioTest
Initialized empty Git repository in /home/daniel/GitMigration/autoAudioTest/.git/
A readme.txt
r1 = b230af6744d36fc61b00327a344aad7c8a31dc12 (refs/remotes/origin/trunk)
A autoAudioTest.py
M readme.txt
A tests/desktop.ini
A tests/sample_tmjl/steps.ini
A tests/sample_tmjl/tmjl-turnoff-light.mp3
A tests/sample_tmjl/tmjl-turnon-light.mp3
A utility/ping.py
A utility/setup/hello.py
A utility/setup/setup.py
A utility/setup/setup_hello.py
W: +empty_dir: trunk/modules
r2 = 3cc5696845e2a0a334d4c56d6d5d30c9616955db (refs/remotes/origin/trunk)
W: +empty_dir: trunk/release
W: +empty_dir: trunk/thirdparty
r3 = c6e7bce2f8e672aa1656ffa76b2fe60ac814358c (refs/remotes/origin/trunk)
A utility/ask_y_n.py
A utility/playmp3.py
r4 = b9d8c0484a0bbe17f5256535057e3b747b95091f (refs/remotes/origin/trunk)
M autoAudioTest.py
r5 = da0a3331de626868d22d642daf6516d16ab1ee56 (refs/remotes/origin/trunk)
A setup.py
D utility/setup/setup.py
W: -empty_dir: trunk/utility/setup/setup.py
r6 = 6f365ae5c8e9ad7b9e3a65673387f34230213cab (refs/remotes/origin/trunk)
M autoAudioTest.py
r7 = 3fdcd4d1a92d2f64cba7411203c54c3ccf7dface (refs/remotes/origin/trunk)
M readme.txt
r8 = a7fa94984f98bfb28b7691161151df853d0e5433 (refs/remotes/origin/trunk)
A release/autoAudioTest_v1.1.8.exe
A releaseNotes.txt
r9 = 827031b61bfd07e465667410d1c4ca3dc9dc4243 (refs/remotes/origin/trunk)
M autoAudioTest.py
A modules/__init__.py
A modules/comfunc.py
r10 = 2f5e0fd8b45813393b3d3350cee9e40ba98b6ae4 (refs/remotes/origin/trunk)
A logs/v010108/t1500_steps.ini
A logs/v010108/t1500_tmjl_result.log
A logs/v010108/t3000_steps.ini
A logs/v010108/t3000_tmjl_result.log
A logs/v010108/t8000_steps.ini
A logs/v010108/t8000_tmjl_result.log
A logs/v010108/t800_steps.ini
A logs/v010108/t800_tmjl_result.log
r11 = e213651fe01a56ad4f6d19c86cb173c01abe2065 (refs/remotes/origin/trunk)
A releaseSteps.txt
r12 = 6a2fba962d8961ae69fad62774578c95627b95e7 (refs/remotes/origin/trunk)
M releaseSteps.txt
r13 = ccac0a0e8e4e9f0b0bd3c00e74443f5d139b7c11 (refs/remotes/origin/trunk)
Checked out HEAD:
svn://192.168.68.200/BloodDiamond-Echo/trunk r13
creating empty directory: thirdparty
$ cd autoAudioTest/
$ git branch -a
* master
remotes/origin/trunk
注:鉴于我们通常是标准的SVN目录管理格式,所以用常规方法即可。
Step 7 Github新建空工程
这一步是Github的操作,这里就忽略了。
注:如果有不太清楚的同学,点击Github上自己【个人头像】–>【Your repositoris】–>【New】新建。
Step 8 Git提交已有工程
进入新建空白工程【code】页面,提示几种新建工程的方法:
Step 9 Git提交经转换的SVN工程
$ git remote add origin git@github.com:lida2003/autoAudioTest.git
$ git remote -v
origin git@github.com:lida2003/autoAudioTest.git (fetch)
origin git@github.com:lida2003/autoAudioTest.git (push)
$ git branch -m master main
$ git push --set-upstream origin main
Enumerating objects: 67, done.
Counting objects: 100% (67/67), done.
Delta compression using up to 2 threads
Compressing objects: 100% (62/62), done.
Writing objects: 100% (67/67), 146.91 MiB | 1.77 MiB/s, done.
Total 67 (delta 28), reused 0 (delta 0)
remote: Resolving deltas: 100% (28/28), done.
remote: error: Trace: eff12eb073130c07d552e733901a707ae6aabee5593ff671aee8df6c4d6b7323
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File release/autoAudioTest_v1.1.8.exe is 145.55 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:lida2003/autoAudioTest.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:lida2003/autoAudioTest.git'
Step 10 解决GH001: Large files detected
看下日志说的“release/autoAudioTest_v1.1.8.exe”是那次提交引入的。
$ git log -n 6
commit ccac0a0e8e4e9f0b0bd3c00e74443f5d139b7c11 (HEAD -> main, origin/trunk)
Author: lida <lida-mail@163.com>
Date: Tue Jul 19 13:00:14 2022 +0000
国内本地镜像源更新
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@13 694d3844-2e77-45a3-bfb9-1339a5765990
commit 6a2fba962d8961ae69fad62774578c95627b95e7
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:33:57 2019 +0000
releaseSteps.txt from previous knowledge to compile and pack to exe command line tools
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@12 694d3844-2e77-45a3-bfb9-1339a5765990
commit e213651fe01a56ad4f6d19c86cb173c01abe2065
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:31:38 2019 +0000
v1.1.8 test data from field
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@11 694d3844-2e77-45a3-bfb9-1339a5765990
commit 2f5e0fd8b45813393b3d3350cee9e40ba98b6ae4
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:27:10 2019 +0000
move some function from autoAudioTest.py to modules/comfunc.py and make it work.
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@10 694d3844-2e77-45a3-bfb9-1339a5765990
commit 827031b61bfd07e465667410d1c4ca3dc9dc4243
Author: lida <lida-mail@163.com>
Date: Wed Jan 30 07:35:53 2019 +0000
autoAudioTest_v1.1.8 Release upload
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@9 694d3844-2e77-45a3-bfb9-1339a5765990
commit a7fa94984f98bfb28b7691161151df853d0e5433
Author: lida <lida-mail@163.com>
Date: Wed Jan 30 07:19:14 2019 +0000
add readme for software "BREACH OF CONTRACT AND RESPONSIBILITY OF EXEMPTION"
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@8 694d3844-2e77-45a3-bfb9-1339a5765990
我们进一步具体可以看到 Commit-ID为827031b61bfd07e465667410d1c4ca3dc9dc4243提交了两个文件:
- release/autoAudioTest_v1.1.8.exe
- releaseNotes.txt
$ git show 827031b61bfd07e465667410d1c4ca3dc9dc4243
commit 827031b61bfd07e465667410d1c4ca3dc9dc4243
Author: lida <lida-mail@163.com>
Date: Wed Jan 30 07:35:53 2019 +0000
autoAudioTest_v1.1.8 Release upload
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@9 694d3844-2e77-45a3-bfb9-1339a5765990
diff --git a/release/autoAudioTest_v1.1.8.exe b/release/autoAudioTest_v1.1.8.exe
new file mode 100644
index 0000000..5d4a7e8
Binary files /dev/null and b/release/autoAudioTest_v1.1.8.exe differ
diff --git a/releaseNotes.txt b/releaseNotes.txt
new file mode 100644
index 0000000..3ed0720
--- /dev/null
+++ b/releaseNotes.txt
@@ -0,0 +1,15 @@
+^M
+^M
+###########################################################^M
+### autoAudioTest_v1.0.6^M
+###########################################################^M
+^M
+# First Releasse^M
+^M
+# MD5SUM^M
+【1】autoAudioTest.exe^M
+==》c683c23f723f9527ef1495c40c5f4197^M
+【2】autoAudioTest_v1.1.8.exe^M
+==》dbac807ea546e50e5cc0a6575c511ad4^M
+^M
+# Know Bugs^M
保存上述两个文件,并进行rebase,丢弃上述Commit-ID为827031b61bfd07e465667410d1c4ca3dc9dc4243的提交
$ git rebase -i a7fa94984f98bfb28b7691161151df853d0e5433
Successfully rebased and updated refs/heads/main.
最新rebase的git 日志显示如下:
$ git log -n 6
commit db6879ce6303db395b36fc7bfc514876700a536b (HEAD -> main)
Author: lida <lida-mail@163.com>
Date: Tue Jul 19 13:00:14 2022 +0000
国内本地镜像源更新
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@13 694d3844-2e77-45a3-bfb9-1339a5765990
commit 9fb35d98a4ac2134141f2969f27897e0cc55363c
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:33:57 2019 +0000
releaseSteps.txt from previous knowledge to compile and pack to exe command line tools
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@12 694d3844-2e77-45a3-bfb9-1339a5765990
commit 05a04613572cee06a862c1cb1a56278e0882d8ba
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:31:38 2019 +0000
v1.1.8 test data from field
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@11 694d3844-2e77-45a3-bfb9-1339a5765990
commit 576f8436f69bdf2c6b449d97dadb269b74e59ea8
Author: lida <lida-mail@163.com>
Date: Sun Mar 3 03:27:10 2019 +0000
move some function from autoAudioTest.py to modules/comfunc.py and make it work.
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@10 694d3844-2e77-45a3-bfb9-1339a5765990
commit a7fa94984f98bfb28b7691161151df853d0e5433
Author: lida <lida-mail@163.com>
Date: Wed Jan 30 07:19:14 2019 +0000
add readme for software "BREACH OF CONTRACT AND RESPONSIBILITY OF EXEMPTION"
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@8 694d3844-2e77-45a3-bfb9-1339a5765990
commit 3fdcd4d1a92d2f64cba7411203c54c3ccf7dface
Author: lida <lida-mail@163.com>
Date: Wed Jan 30 06:40:44 2019 +0000
Fix internal player use configuration read issue.
git-svn-id: svn://192.168.68.200/BloodDiamond-Echo/trunk@7 694d3844-2e77-45a3-bfb9-1339a5765990
Step 11 Git再次提交经转换的SVN工程
$ git push --set-upstream origin main
Enumerating objects: 62, done.
Counting objects: 100% (62/62), done.
Delta compression using up to 2 threads
Compressing objects: 100% (57/57), done.
Writing objects: 100% (62/62), 1.60 MiB | 756.00 KiB/s, done.
Total 62 (delta 27), reused 0 (delta 0)
remote: Resolving deltas: 100% (27/27), done.
To github.com:lida2003/autoAudioTest.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
Step 12 Github刷新工程
Rebase后面的git记录在web页面上显示是rebase的时间,不过git log下还是以前的时间。
3. autoAudioTest之单循环测试视频
天猫精灵+YeeLight 智能灯泡+电压电流计+2019自动测试
4. autoAudioTest手册&版本
- 智能光源语音控制专项测试工具使用说明书v1
- 智能光源语音控制专项测试工具验证环境搭建v1
- autoAudioTest_v1.1.8.a7fa949 Release
5. 参考资料
【1】Migrate from SVN to Git