mac 下svn 代码迁移到git

安装

clone svn
kevinxwdeMacBook-Air:git-project kevin$ git svn clone http://sources.***.net/svn/***/branches/spider-forked --no-metadata myspider
Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: 

refer:
* http://blog.puhao.me/%E5%90%90%E6%A7%BD/OS-X-Yosemite(10.10)%E4%B8%8B%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8git-svn%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/

update svn
setting
kevinxwdeMacBook-Air:git-project kevin$ sudo ln -s /Library/Developer/CommandLineTools/Library/Perl/5.18/darwin-thread-multi-2level/SVN  /System/Library/Perl/Extras/5.18/SVN
kevinxwdeMacBook-Air:git-project kevin$ sudo ln -s /Library/Developer/CommandLineTools/Library/Perl/5.18/darwin-thread-multi-2level/auto/SVN/  /System/Library/Perl/Extras/5.18/auto/SVN

使用 git svn clone 一个svn的工程到本地

kevinxwdeMacBook-Air:git-project kevin$ git svn clone http://sources.comp.net/svn/asc_search_engine/branches/spider-forked myspider --no-metadata --authors-file=author.txt

成功执行会有类似如下输出

W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
Checked Ahrough mkdocs.yml
    A   LICENSE
    A   .travis.yml
    A   setup.py
    A   docs/Deployment.md
    A   docs/imgs/developer-tools-network-filter.png
    A   docs/imgs/inspect_element.png
    A   docs/imgs/search-for-request.png
    A   docs/imgs/run_one_step.png
    A   docs/imgs/request-headers.png
    A   docs/imgs/creating_a_project.png
    A   docs/imgs/twitch.png
    ....
    Checked out HEAD: http://sources.comp.net/svn/asc_search_engine/branches/spider-forked r4690

注意:如果提示 有用户不再 –authors指定的文件里, git svn clone 是失败的,可以用echo $? 一定是非0, 本地目录是个空目录, 一定要在再添加author.txt

完成后,进入本地工程目录, 可以用git log查看该工程的日志。此时,原有的svn log都 转为了git log.

kevinxwdeMacBook-Air:myspider kevin$ git log
commit 61879afb2af90651e33dc6c7003715fc722a8da6
Author: wei.xiew <wei.xiew@comp.com>
Date:   Fri Nov 6 15:27:23 2015 +0000

    Myspider: remove some original docs of 'pyspider',  and an account and ip info in the conf file

commit 32500016d6a088a18117963a52b7361a1112804b
Author: wei.xiew <wei.xiew@comp.com>
Date:   Fri Nov 6 08:52:13 2015 +0000

    Myspider: rename storage as data pipe

commit 6c0981fc2afbfdfc21badd46b2433b770a7d2b30
Author: wei.xiew <wei.xiew@comp.com>
Date:   Fri Oct 30 02:21:21 2015 +0000

    [fix #6561531][R123207]Myspider: a url seed db with mysql

git remote add 命令该工程与gitlab上的project对接, 随后可用git remote -v 查看源
gitlab 的project在gitlab的页面上创建, 会得到project的地址:git@gitlab.comp.com:cd-op/myspider.git

kevinxwdeMacBook-Air:myspider kevin$ git remote add origin git@gitlab.comp.com:cd-op/myspider.git
kevinxwdeMacBook-Air:myspider kevin$ git remote -v
origin  git@gitlab.comp.com:cd-op/myspider.git (fetch)
origin  git@gitlab.comp.com:cd-op/myspider.git (push)

将工程推进github

kevinxwdeMacBook-Air:myspider kevin$ git push -u origin master
The authenticity of host 'gitlab.alipay-inc.com (100.67.50.13)' can't be established.
RSA key fingerprint is a4:41:80:60:b1:48:ee:b5:57:6b:8a:f5:d8:96:43:06.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.comp.com,100.67.50.13' (RSA) to the list of known hosts.
Counting objects: 358, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (351/351), done.
Writing objects: 100% (358/358), 2.16 MiB | 539.00 KiB/s, done.
Total 358 (delta 141), reused 0 (delta 0)

To git@gitlab.comp.com:cd-op/myspider.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

完成迁移,可以在gitlab project 上看到所有代码

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Git代码迁移SVN是一个复杂的过程,需要一定的技术知识和操作。下面是一个完整的详细教程,以帮助您进行Git代码SVN迁移: 1. 准备工作: - 确保您的系统上已安装GitSVN。您可以从官方网站下载并安装它们。 - 确保您有读取Git仓库和写入SVN仓库的权限。 2. 创建一个空的SVN仓库: - 使用SVN创建一个新的空仓库,用于存储迁移后的代码和历史记录。 3. 克隆Git仓库: - 在本地选择一个目录,使用以下命令克隆Git仓库: ``` git clone <Git仓库URL> ``` 4. 配置Git-svn: - 在克隆的Git仓库目录中,运行以下命令来配置Git-svn: ``` git svn init <SVN仓库URL> --prefix=svn/ --no-metadata ``` - `<SVN仓库URL>` 是目标SVN仓库的URL。 - `--prefix=svn/` 参数将创建的SVN分支和标签的前缀设置为 "svn/"。 5. 迁移代码和提交记录: - 使用以下命令将Git提交记录迁移SVN: ``` git svn fetch ``` - 该命令会将所有Git提交记录逐一导入到SVN仓库中。 6. 提交到SVN仓库: - 进入新创建的SVN仓库目录,使用以下命令提交到SVN仓库: ``` svn add --force . svn commit -m "Initial import from Git" ``` 7. 验证迁移结果: - 检查SVN仓库中的代码和提交记录,确保迁移成功。 请注意,由于GitSVN之间存在一些概念和功能上的差异,一些高级特性(如分支、标签和Git特有的元数据)可能无法完全迁移。在进行迁移之前,请充分测试,并确保备份重要的数据。 此外,这只是一个基本的示例教程,实际迁移的复杂性取决于您的项目和仓库结构。如果您有特定的要求或遇到了问题,请提供更多关于您的项目和环境的信息,以便我能够提供更准确的建议。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值