Git-svn - 导入完整历史 [英] Git-svn - import full history

查看:44
本文介绍了Git-svn - 导入完整历史的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

默认情况下,git svn clone 仅从分支创建开始导入历史记录,尽管事实上,文件的历史记录存在于分支创建之前的 SVN 存储库中.

By default git svn clone imports history only from branch creation onwards, despite the fact, that history for files is present in SVN repository prior branch creation.

如果重要的话,我们的 SVN 分支是由 svn copy 创建的.

Our SVN branch was created by svn copy, if that matters.

我的尝试

我尝试了 --no-minimize-url--follow-parent,但没有成功.生成的 Git 仓库和没有这些参数一样,从创建分支开始.

I've tried --no-minimize-url and --follow-parent, but without success. Produced Git repository is same as without these params, starting from branch creation.

想要的结果

具有 SVN 存储库创建的完整历史记录的 Git 存储库.

Git repository with full history from SVN repository creation.

更新

我的实际命令行是

git svn clone http://svnserver/repo/dir1/dir2/project

有帮助的是 -T 参数和结果命令:

What helped was -T argument with resulting command:

git svn clone http://svnserver/repo/ -T dir1/dir2/project

推荐答案

默认情况下 git svn clone 仅从分支创建导入历史记录之后,尽管事实上,文件的历史记录存在于 svn 中存储库之前的分支创建.

By default git svn clone imports history only from branch creation onwards, despite the fact, that history for files is present in svn repository prior branch creation.

是的.那是真实的.git svn 只会在被告知时尝试将分支作为分支导入.来自 git-svn 的联机帮助页:

Yes. that is true. git svn will only try to import branches as branches if it is told so. From the manpage of git-svn:

当克隆一个 SVN 存储库时,如果没有用于描述的选项使用存储库布局(--trunk、--tags、--branches、--stdlayout),git svn clone 将创建一个具有完全线性历史的 git 存储库,其中分支和标签显示为单独的工作副本中的目录.

When cloning an SVN repository, if none of the options for describing the repository layout is used (--trunk, --tags, --branches, --stdlayout), git svn clone will create a git repository with completely linear history, where branches and tags appear as separate directories in the working copy.

如果您将一个分支的 URL 传递给 git svn clone(而不是顶级 URL),您将只能获得该分支的线性历史记录.这可能就是您所看到的.

If you pass the URL for one branch to git svn clone (instead of the top-level URL), you'll only get the linear history for that branch. That is probably what you are seeing.

如果您想要完整的历史记录,请使用上面提到的存储库布局选项,并传递顶级 URL.然后 git svn 将尝试为 SVN 分支创建 git 分支,并尝试为它们提供正确的历史记录,在它们创建之前返回.

If you want full history, use the repository layout options mentioned above, and pass the top-level URL. Then git svn will try to create git branches for SVN branches, and will try to give them the right history, going back before their creation.

请注意,这将为您提供包含所有分支的完整存储库.如果您只需要一些分支,则需要按照手册页中的说明修改配置:

Note that this will give you the complete repository with all branches. If you only want some branches, you need to modify your configuration as explained in the manpage:

也可以通过使用大括号内以逗号分隔的名称列表.例如:

It is also possible to fetch a subset of branches or tags by using a comma-separated list of names within braces. For example:

       [svn-remote "huge-project"]
               url = http://server.org/svn
               fetch = trunk/src:refs/remotes/trunk
               branches = branches/{red,green}/src:refs/remotes/branches/*
               tags = tags/{1.0,2.0}/src:refs/remotes/tags/*

请参阅git-svn(1).

这篇关于Git-svn - 导入完整历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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