前言:

  最近公司需要将整体项目从svn迁移至gitlab上,经过几天的研究,现记录一下流程

  整体思路是进行一次导入:

  先通过subgit将svn整个import至本地,在与git上的项目进行合并.

1.硬件环境

  git:git version 2.7.4
  svn: 1.6.11

   subgit:3.2.2
2.下载subgit

  官网下载subgit: https://subgit.com/

  将subgit解压:    

tar -zcvf subgit-3.2..zip 

3.在gitlab上新建一个需要合并的项目

  进入gitlab管理界面,新建项目:lclctest  

git@xx.xx.xx.xx:lclc/lclctest.git (我这边新建了一个lclc的组)

  建好以备用.

4.进入subgit-3.2.2/bin 目录,使用configure命令  

./subgit configure http://ip:port/svn/lclctest  lclctest

完成后会有一些提示:  

) Adjust Subversion to Git branches mapping if necessary:
/root/lclctmp/tmp/subgit-3.2./bin/lclctest/subgit/config
) Define at least one Subversion credentials in default SubGit passwd file at:
/root/lclctmp/tmp/subgit-3.2./bin/lclctest/subgit/passwd
OR configure SSH or SSL credentials in the [auth] section of:
/root/lclctmp/tmp/subgit-3.2./bin/lclctest/subgit/config
) Optionally, add custom authors mapping to the authors.txt file(s) at:
/root/lclctmp/tmp/subgit-3.2./bin/lclctest/subgit/authors.txt
) Run SubGit 'install' command:
subgit install lclctest

意思是进行一些配置,然后进行install

  配置config:由于3.2.2默认是配置好的,可以不进行配置  

trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
branches = branches/features/*:refs/heads/features/*
branches = hotfixes/*:refs/heads/hotfixes/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*

  配置用户映射文件 author.txt 格式为:svnUser = Git User <user@example.com> (也可以不修改)
5.进行install

$ ./subgit install lclctest

  此步将连接svn,需要耗时一段时间.

  完成后就把svn代码迁移到本地库了,这时候就需要用git push到远程库中

6.clone版本  

 git clone ./lclctest lclctest.git

7.进入lclctest.git目录  

git remote set-url origin git@yourip:lclc/lclctest.git(之前创建的git项目)
git push origin master

  在push的时候发现提示填写密码:  

 git@ip's password:

  此时说明需要进行身份验证,我们给git添加一个keygen就行了

  7.1:生成keygen 

cd ~
ssh-keygen -t rsa -C "your_email@example.com"

  生成的文件在 .ssh文件下有 id_rsa和id_rsa.pub文件

  7.2:上传keygen

  打开gitlab的管理界面

  

将id_rsa.pub文件中的内容复制到Key的文本框里.

再执行步骤7的git push origin master命令上传master

8.上传分支.

  进入lclctest.git目录,使用命令查看分支  

git branch -a

结果:

* master
remotes/origin/HEAD -> origin/master
remotes/origin/bugfix
remotes/origin/develop
remotes/origin/feature
remotes/origin/master

本项目一共有3个分支,分别是bugfix,develop,feature,分别进行上传

git push origin remotes/origin/feature:refs/heads/feature
git push origin remotes/origin/bugfix:refs/heads/bugfix
git push origin remotes/origin/develop:refs/heads/develop

注意:冒号后面为远程库中的地址,必须以refs/heads开头.

9.上传tags

git push --tags

参考资料:

  http://lattecake.com/post/20051

  http://stackoverflow.com/questions/23251394/subgit-import-and-multiple-branches-directories

使用subgit进行svn迁移至git(branch,tags)的更多相关文章

  1. SVN迁移到Git的过程(+ 一些技巧)

    SVN迁移到Git的过程(+ 一些技巧) 李顺利 Key Words SVN,Git,Clone,Conversion,Tips,VCS,Pro Git 关于在VCS中SVN和Git之间的迁移(Clo ...

  2. SVN迁移到Git的过程(+ 一些技巧

    关于在VCS中SVN和Git之间的迁移(Clone)这个部分网上已经有大批的文章介绍,而且都非常不错,能够满足我们的常见的需求,这里介绍的是我自己整理的一些技巧和使用中出现的一些问题和疑问.阅读本篇文 ...

  3. svn迁移到git仓库并保留commit历史记录

    svn迁移到git仓库并保留commit历史记录 最近在做svn迁移到gitlab,由于之前一直是由svn做版本控制.最简单的方式是将svn的内容export出来,然后添加到gitlab即可.但是,如 ...

  4. svn 迁移至git操作手册

    svn 迁移至git操作手册 项目交付.版本管理工具变更等情况下,迁移svn旧历史记录有很大必要,方便后续追踪文件的提交历史,文件修改记录比对等.git自带了从svn迁移至git的工具命令,可很好的对 ...

  5. git学习------>从SVN迁移到Git之后,项目开发代码继续在SVN提交,如何同步迁移之后继续在SVN提交的代码到Git?

    最近逐步逐步的将公司的项目都从SVN往Git迁移了,但是想团队成员都能够一步到位就迁移到Git是不可能的,因为还有大部分人都还不会Git,所以整个过渡过程估计得大半年. 因此导致虽然项目迁移过来了,但 ...

  6. 将代码库从 SVN 迁移至 Git 并保留所有 commit 记录

    公司内部原本使用 SVN 进行版本控制,但随着 Github 的流行我个人的代码管理习惯逐渐转变.虽然公司项目并非开源,SVN 所具有的标准 trunk / branches / tags 结构完全够 ...

  7. svn迁移到git

    步骤命令如下: > git svn clone https://svn-url/ProjectName --no-metadata --authors-file=user.txt --trunk ...

  8. 从svn迁移至Git并保留所有 commit 记录

    用户映射文件user.txt,等号左边为svn账号,右边为Git用户名和邮箱.注意:svn中有多少用户就要映射多少 test1=test1<147258369@qq.com>test2=t ...

  9. svn 迁移到 git 仓库并保留 commit 历史记录

    1.svn 转换为 git(会提示,让你输入先前 svn 的账号与密码) # 切换至 本地项目目录 cd /Users/jianbao/PhpStormProjects/fiisoo/ # 克隆 sv ...

随机推荐

  1. (转)mmap和shm共享内存的区别和联系

    共享内存的创建 根据理论: 1. 共享内存允许两个或多个进程共享一给定的存储区,因为数据不需要来回复制,所以是最快的一种进程间通信机制.共享内存可以通过mmap()映射普通文件 (特殊情况下还可以采用 ...

  2. Java代码优化(一)

    前言 2016年3月修改,结合自己的工作和平时学习的体验重新谈一下为什么要进行代码优化.在修改之前,我的说法是这样的: 就像鲸鱼吃虾米一样,也许吃一个两个虾米对于鲸鱼来说作用不大,但是吃的虾米多了,鲸 ...

  3. Elasticsearch 健康状态处理

    笔者在自己的 ubuntu 服务器上使用 GET /_cat/health?v 命令时,返回值如下所示 可以看到集群状态为 yellow,这是什么意思呢?原来在 es 的集群状态中,有三种情况,官网描 ...

  4. nginx backend 健康检查

    ngx_http_proxy_module 模块和ngx_http_upstream_module模块(自带) 严格来说,nginx自带是没有针对负载均衡后端节点的健康检查的,但是可以通过默认自带的n ...

  5. N个不同球取出M个的组合个数求解

    Technorati 标签: 组合,概率 从N个不同的球中取出M个,一共有多少种取法? 这个问题是组合数据的基本问题,考虑拿出球是否放回,拿出去的球是否有序,它有4种变体: 不放回,有序: 不放回,无 ...

  6. net生成图片验证码--转自Lisliefor

    目前,机器识别验证码已经相当强大了,比较常见的避免被机器识别的方法,就是将验证码的字符串连到一起,这样就加大的识别的难度,毕竟机器没有人工智能.我找了很多的.net生成图片验证码的例子,后来经过一些修 ...

  7. C# wpf InkCanvas 保存图片jpg

    前端xaml页面代码 <Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.micr ...

  8. Visual Studio 编译信息细度显示设置

    visual studio 项目在编译时,可根据调试需要设置output窗口输出内容的详细程度,这对于bug或warning的解决具有很大帮助.具体设置如下: 依次点击:"Tools&quo ...

  9. 790. Domino and Tromino Tiling

    We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may ...

  10. 蒲公英(bzoj2724)(分块+区间众数)

    Input Output Sample Input 6 3 1 2 3 2 1 2 1 5 3 6 1 5 Sample Output 1 2 1 HINT \(n <= 40000\),$ m ...