具有复杂结构的Git SVN克隆 [英] Git SVN clone with complex structure
问题描述
我需要将SVN存储库克隆到git. SVN储存库的结构就像是一个储存库一样,
I need to clone an SVN repository to git. The SVN repository is structured as if it's a repository of repositories, like so:
SVNRepo
|____ProjectA
| |___branches
| |___tags
| |___trunk
| file
|____ProjectB
| |___branches
| |___tags
| |___trunk
file
我需要克隆存储库,以便最终得到一个单独的git存储库,而没有svn特定的文件夹(分支,标签,主干).我最初将其转储,然后将SVN存储库拆分为每个项目的单独存储库,并使用git svn clone和--stdlayout命令迁移到git.这行得通,但随之而来的是我们团队已否决了自己的问题.
I need to clone the repository so that I end up with a single git repository, without the svn specific folders (branches, tags, trunk). I originally dumped then split the SVN repo into separate repos for each project and migrated to git using git svn clone with the --stdlayout command. This worked but came with it's own issues that have been vetoed by our team.
我使用--stdlayout命令尝试了git svn clone ,但这不起作用.我最终得到一个空的git repo,其中包含2次提交(总共数百次提交),并且没有实际的文件.没有错误,所以我不确定发生了什么.
I tried the git svn clone with the --stdlayout command but that doesn't work. I end up with an empty git repo with 2 commits (out of hundreds) and no actual files. There were no errors so I'm not sure what happened.
尝试git svn clone 而没有--stdlayout之类的工作,因为我得到了一个包含所有文件和历史记录的git repo.但是,我仍然要删除所有分支,标签和中继文件夹.
Trying git svn clone without the --stdlayout sort of works, in that I get a single git repo with all files and history. However, I still have all of the branches, tags and trunk folders which I've like to remove.
我已经考虑过转储SVN存储库,并使用sed编辑二进制文件,但这似乎需要大量工作.我想象有人遇到了这个问题并解决了问题,但找不到任何有效的方法.
I've considered dumping the SVN repo and using sed to edit the binary but that seems like a lot of work. I imagine someone else has encountered this and solved the problem but can't find anything that works.
推荐答案
对于一次性迁移,git-svn
不是不是用于存储库或存储库部件转换的正确工具.如果要将Git用作现有SVN服务器的前端,这是一个很好的工具,但是对于一次性转换,您不应该使用git-svn
,而svn2git
则更适合这个用例.
For a one-time migration git-svn
is not the right tool for conversions of repositories or repository parts. It is a great tool if you want to use Git as frontend for an existing SVN server, but for one-time conversions you should not use git-svn
, but svn2git
which is much more suited for this use-case.
有很多名为svn2git
的工具,可能最好的工具是来自 https://github.com/svn-all-fast-export/svn2git .我强烈建议使用该svn2git
工具.这是我所知道的最好的,它在处理规则文件方面非常灵活.
There are plenty tools called svn2git
, the probably best one is the KDE one from https://github.com/svn-all-fast-export/svn2git. I strongly recommend using that svn2git
tool. It is the best I know available out there and it is very flexible in what you can do with its rules files.
您将能够轻松配置svn2git
规则文件,以从当前SVN布局中生成所需的结果.
You will be easily able to configure svn2git
s rule file to produce the result you want from your current SVN layout.
如果您不是100%了解存储库的历史记录,请从 http://blog.hartwork.org/?p=763 是在将SVN储存库迁移到Git时研究其历史的好工具.
If you are not 100% about the history of your repository, svneverever
from http://blog.hartwork.org/?p=763 is a great tool to investigate the history of an SVN repository when migrating it to Git.
尽管git-svn
较容易入门,但还有一些其他原因为何除了灵活性之外,使用KDE svn2git
代替git-svn
更为优越:
Even though git-svn
is easier to start with, here are some further reasons why using the KDE svn2git
instead of git-svn
is superior, besides its flexibility:
- 通过
svn2git
(如果使用了正确的历史记录),可以更好地重建历史记录,并且更整洁(对于使用分支和合并等更复杂的历史记录,尤其如此) - 标签是真实标签,不是Git中的分支
- 带有
git-svn
的标记包含一个额外的空提交,这也使它们不属于分支,因此普通的fetch
不会获得它们,直到您将--tags
赋予命令为止,因为默认情况下仅指向提取的分支也将被提取.带有正确的svn2git标签是它们所属的地方 - 如果您在SVN中更改了布局,则可以轻松地使用
svn2git
进行配置,而使用git-svn
最终会丢失历史记录 - 使用
svn2git
,您还可以轻松地将一个SVN存储库拆分为多个Git存储库 - 或将同一SVN根目录中的多个SVN存储库轻松组合到一个Git存储库中
- 正确的
svn2git
转换要比git-svn
快几千亿倍
- the history is rebuilt much better and cleaner by
svn2git
(if the correct one is used), this is especially the case for more complex histories with branches and merges and so on - the tags are real tags and not branches in Git
- with
git-svn
the tags contain an extra empty commit which also makes them not part of the branches, so a normalfetch
will not get them until you give--tags
to the command as by default only tags pointing to fetched branches are fetched also. With the proper svn2git tags are where they belong - if you changed layout in SVN you can easily configure this with
svn2git
, withgit-svn
you will loose history eventually - with
svn2git
you can also split one SVN repository into multiple Git repositories easily - or combine multiple SVN repositories in the same SVN root into one Git repository easily
- the conversion is a gazillion times faster with the correct
svn2git
than withgit-svn
您看到,git-svn
较差而KDE svn2git
较优的原因很多. :-)
You see, there are many reasons why git-svn
is worse and the KDE svn2git
is superior. :-)
这篇关于具有复杂结构的Git SVN克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!