简体   繁体   English

Git-svn可以用于大型分支存储库吗?

[英]Can Git-svn be used on large, branched repositories?

I am trying to use Git as a frontend to a SVN repository in order to be able to use Git's nice features like simple branching, stashing etc. 我正在尝试使用Git作为SVN存储库的前端,以便能够使用Git的简单分支,存储等优秀功能。

The problem is that the SVN repository is quite large (8,000 revs) and contains lots of branches and tags (old as well as new). 问题是SVN存储库非常大(8,000转)并且包含许多分支和标记(旧的和新的)。

It's a near standard layout, with a config containing fetch, branches and tags directives. 它是一个接近标准的布局,配置包含fetch,branches和tags指令。

Since the oldest branch and tag refers to revision 10, it means that every svn fetch reads the entire repository history from revision 10 and forward, which can takes hours on the slow connection. 由于最旧的分支和标记引用了修订版10,这意味着每个svn fetch都会从修订版10和转发文件中读取整个存储库历史记录,这可能需要数小时的慢速连接。

If I only track trunk, then it's fine, but I still want to make git aware of new branches and tags. 如果我只跟踪主干,那么它很好,但我仍然想让git意识到新的分支和标签。

I usually look at git log -1 on the branch I'm at and gets the SVN revision from the comment, so I can do git svn fetch -r7915:HEAD or similar. 我通常在我所在的分支上查看git log -1并从注释中获取SVN修订版,因此我可以执行git svn fetch -r7915:HEAD或类似操作。 I guess that's what git svn fetch --parent does. 我想这就是git svn fetch --parent所做的。 But why do I need to do this? 但为什么我需要这样做呢?

I'm on Windows, and use TortoiseGit which has quite nice support for git-svn , but since TortoiseGit only runs git svn fetch I'm kind of stuck. 我在Windows上,并使用TortoiseGit,它对git-svn有很好的支持,但由于TortoiseGit只运行git svn fetch我有点卡住了。

Am I doing something wrong? 难道我做错了什么? I expect svn fetch to be a fast operation when the first svn clone -s is complete. 我希望当第一个svn clone -s完成时, svn fetch是一个快速操作。

Thanks for the answers. 谢谢你的回答。 They did not really help me, though. 但他们并没有真正帮助我。

This command is the best solution so far: 到目前为止,此命令是最佳解决方案:

git svn log --all -1 | \
  sed -n '2s/r\\([0-9]*\\).*/\\1/p' | \
  xargs --replace=from git svn fetch -r from:HEAD

It uses git svn log --all to find the highest SVN revision number fetched so far, and fetches everything from that point onwards. 它使用git svn log --all来查找到目前为止获取的最高SVN修订版号,并从该点开始提取所有内容。

I wish git svn fetch would have an option to behave like this. 我希望git svn fetch可以选择像这样。 Unless the SVN revisions are changed, there is no reason git svn should fetch the same revisions over and over each time. 除非更改SVN修订版,否则git svn没有理由每次都反复获取相同的修订版。

If you do not need to have full history in the git repository, I recommend you take a look at the "git + svn" approach, detailed in the link below, instead of the standard git-svn integration. 如果您不需要在git存储库中拥有完整的历史记录,我建议您查看下面链接中详细介绍的“git + svn”方法,而不是标准的git-svn集成。 Your initial import into git should be very quick, since you will not be importing history. 您最初导入git应该非常快,因为您不会导入历史记录。

Make sure to read the section entitled "Benefits, Drawbacks, and Lessons Learned". 请务必阅读标题为“福利,缺点和经验教训”的部分。

http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx http://www.lostechies.com/blogs/derickbailey/archive/2010/02/03/branch-per-feature-how-i-manage-subversion-with-git-branches.aspx

You're using it correctly: the initial import of a Subversion repository with lots of history will be very slow. 您正确使用它:初始导入具有大量历史记录的Subversion存储库将非常缓慢。

The bad news is because Subversion's branches and tags are only directories, git-svn is forced to take the pessimistic route of reading each branch from its head all the way back to the first revision. 坏消息是因为Subversion的分支和标签只是目录, git-svn被迫采取悲观的方式从头部一直读回第一个修订版。 Yes, if you've been disciplined in your use of Subversion, this will result in many fetches of the same data, but real-world usage patterns make this an unlikely case. 是的,如果您在使用Subversion时受过纪律处分,这将导致许多相同数据的提取,但实际使用模式使这不太可能。

Start the clone in the evening and come back to a nice git repo the next morning! 晚上开始克隆,第二天早上回到一个漂亮的git repo!

Once you've cloned, git svn fetch even warns you: 一旦你克隆了, git svn fetch甚至会警告你:

This may take a while on large repositories

Subversion is simple and stupid, so git has to take things slowly. Subversion简单而愚蠢,所以git必须慢慢来。

Do you have symlinks in the SVN repo? 你在SVN回购中有符号链接吗? If not, have you tried this setting: 如果没有,您是否尝试过此设置:

svn.brokenSymlinkWorkaround svn.brokenSymlinkWorkaround

This disables potentially expensive checks to workaround broken symlinks checked into SVN by broken clients. 这会禁用可能昂贵的检查,以解决由损坏的客户端检入SVN的损坏的符号链接。 Set this option to "false" if you track a SVN repository with many empty blobs that are not symlinks. 如果跟踪具有许多非符号链接的空blob的SVN存储库,请将此选项设置为“false”。 This option may be changed while git svn is running and take effect on the next revision fetched. 当git svn正在运行时,可以更改此选项,并在获取的下一个修订版本上生效。 If unset, git svn assumes this option to be "true". 如果未设置,git svn假定此选项为“true”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM