[英]How to import svn branch to git with trunk history
This is the svn trunk
path:这是 svn
trunk
路径:
http://svn/path/libs/trunk/mylib
And here is the branch
path:这是
branch
路径:
http://svn/path/libs/branches/mylib/mylib-feature-branch
I need to migrate only the branch to git, but I also need its trunk history before the branch was created.我只需要将分支迁移到 git,但在创建分支之前我还需要它的主干历史记录。
The following command fetches only the branch history:以下命令仅获取分支历史记录:
git svn clone http://svn/path/libs/branches/mylib/mylib-feature-branch
I have read this answer , but could not figure out how I should change the git svn clone
command to have the full history of the branch.我已阅读此答案,但无法弄清楚应该如何更改
git svn clone
命令以获取分支的完整历史记录。 Any advice would be appreciated.任何意见,将不胜感激。
git-svn
is not the right tool for one-time conversions of repositories or repository parts. git-svn
不是一次性转换存储库或存储库部分的正确工具。 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.这是一个伟大的工具,如果你想使用Git的作为前端为现有的SVN服务器,但对于一次性转换,你不应该使用
git-svn
,但svn2git
这是更适合这个用例。
There are pleny tools called svn2git
, the probably best one is the KDE one from https://github.com/svn-all-fast-export/svn2git .有很多工具叫做
svn2git
,最好的一个可能是来自https://github.com/svn-all-fast-export/svn2git的 KDE 工具。 I strongly recommend using that svn2git
tool.我强烈推荐使用那个
svn2git
工具。 It is the best I know available out there and it is very flexible in what you can do with its rules files.这是我所知道的最好的,而且它的规则文件非常灵活。
You will easily be able to set up the rules file so that exactly your branch and its history will get migrated.您将能够轻松地设置规则文件,以便准确地迁移您的分支及其历史记录。
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.如果您不是 100% 了解存储库的历史,
svneverever
http://blog.hartwork.org/?p=763中的svneverever
是一个很好的工具,可以在将 SVN 存储库迁移到 Git 时调查其历史记录。
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:尽管 git-svn 更容易开始,以下是使用 KDE
svn2git
而不是git-svn
更优越的一些进一步原因,除了它的灵活性:
svn2git
(if the correct one is used), this is especially the case for more complex histories with branches and merges and so on svn2git
(如果使用正确的) 重建历史会更好更干净,尤其是对于具有分支和合并等更复杂的历史的情况git-svn
the tags contain an extra empty commit which also makes them not part of the branches, so a normal fetch
will not get them until you give --tags
to the command as by default only tags pointing to fetched branches are fetched also.git-svn
标签包含一个额外的空提交,这也使它们不属于分支的一部分,因此在您将--tags
给命令之前,正常的fetch
不会获取它们,因为默认情况下只有指向已提取分支的标签也被提取. With the proper svn2git tags are where they belongsvn2git
, with git-svn
you will loose history eventuallysvn2git
轻松配置它,使用git-svn
您最终会丢失历史记录svn2git
you can also split one SVN repository into multiple Git repositories easilysvn2git
您还可以轻松地将一个 SVN 存储库拆分为多个 Git 存储库svn2git
than with git-svn
svn2git
比使用git-svn
快上无svn2git
There are many reasons why git-svn
is worse and the KDE svn2git
is superior. git-svn
更差而 KDE svn2git
更优的原因有很多。 :-) :-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.