Git-svn - 导入完整历史

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15163916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:15:19  来源:igfitidea点击:

Git-svn - import full history

gitsvngit-svn

提问by Hoppus Hoppard

Problem

问题

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

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

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

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

My attempts

我的尝试

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

我试过--no-minimize-url--follow-parent,但没有成功。从分支创建开始,生成的 Git 存储库与没有这些参数的情况相同。

Desired result

想要的结果

Git repository with full history from SVN repository creation.

具有 SVN 存储库创建的完整历史的 Git 存储库。

Update

更新

My actual command line was

我的实际命令行是

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

What helped was -Targument with resulting command:

有帮助的是-T结果命令的争论:

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

采纳答案by sleske

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 clone 仅从分支创建开始导入历史记录,尽管事实上,文件的历史记录存在于分支创建之前的 svn 存储库中。

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

是的。那是真实的。git svn如果被告知,只会尝试将分支导入为分支。从 git-svn 的联机帮助页:

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.

克隆一个 SVN 仓库时,如果没有使用任何描述仓库布局的选项(--trunk、--tags、--branches、--stdlayout),git svn clone 将创建一个完全线性历史的 git 仓库,其中分支和标签在工作副本中作为单独的目录出现。

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 clone(而不是顶级 URL),您将只能获得该分支的线性历史记录。这可能就是你所看到的。

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

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

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/*

也可以通过在大括号内使用逗号分隔的名称列表来获取分支或标签的子集。例如:

       [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/*

See git-svn(1).

参见git-svn(1)

回答by sjas

http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Gitdescribes how to import branches and tags properly.

http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git描述了如何正确导入分支和标签。