Git-2-SVN 迁移? [英] Git-2-SVN migration?

查看:26
本文介绍了Git-2-SVN 迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道.为什么要从 Git 迁移到 SVN?

Yes, I know. Why would you want to migrate from Git to SVN?

好吧,我碰巧遇到了需要将一个巨大的 Git 存储库迁移到 Subversion 的情况!这是我根据 Edwin 的评论尝试的一个工作流程:

Well I happen to be in a situation that I need to migrate a huge Git repo to Subversion! Here's one workflow I tried per Edwin's comment:

首先创建一个本地 SVN repo:svnadmin 创建 svn_repo

first create a local SVN repo: svnadmin create svn_repo

接下来我查看我的 Git 存储库:git clone git:myNameSpace/myProject

Next I check out my Git repo: git clone git:myNameSpace/myProject

cd 进入 myProject 并运行:

git svn init -s --prefix=svn/file:///home/myHome/svn_repo/myProject

git svn fetch

git rev-list --parents master |grep '^.{40}$' 来查找你的根提交的哈希值并只给出一个提交.

git rev-list --parents master | grep '^.{40}$' to look up the hash of your root commit and gives only one commit as it should.

接下来是获取空主干提交的哈希:git rev-parse svn/trunk

Next is to get the hash of the empty trunk commit: git rev-parse svn/trunk

不幸的是,这个失败了:

This one unfortunately fails with:

致命:不明确的参数svn/trunk":未知的修订版或路径不在工作树中.使用 '--' 将路径与修订分开

好吧,在这之后我不能走太多......

Well I can't go much after this....

推荐答案

我建议您通过几个简单的步骤使用 SubGit 进行迁移.

I would recommend you to migrate that with SubGit in several easy steps.

$ svnadmin create svn.repo
$ subgit configure svn.repo
$ nano svn.repo/conf/subgit.conf #edit path to your (bare!) Git repository (you may use "git clone --bare <URL> bare.git.repo" if you don't have it locally)
$ subgit install

就是这样.虽然翻译 SubGit 会尽量保留所有提交(甚至是临时的)、分支、合并、忽略、日期、EOL 设置、标签等.

That's all. While translation SubGit will try to preserve all commits (even temporary), branches, merges, ignores, dates, EOLs settings, tags and so on, as it it possible.

翻译后存储库将同步(每次推送到 Git 都会翻译为 SVN 修订版,反之亦然).中断同步(如果你不需要的话)运行

After translation the repositories will be in sync (each push to Git is translated to SVN revision and vice versa). To break synchronization (if you don't need it) run

$ subgit uninstall svn.repo

这篇关于Git-2-SVN 迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆