简体   繁体   English

如何使用主干历史将 svn 分支导入到 git

[英]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更优越的一些进一步原因,除了它的灵活性:

  • 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 svn2git (如果使用正确的) 重建历史会更好更干净,尤其是对于具有分支和合并等更复杂的历史的情况
  • the tags are real tags and not branches in Git标签是真正的标签,而不是 Git 中的分支
  • with 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 belong使用正确的 svn2git 标签是它们所属的地方
  • if you changed layout in SVN you can easily configure this with svn2git , with git-svn you will loose history eventually如果您更改了 SVN 中的布局,您可以使用svn2git轻松配置它,使用git-svn您最终会丢失历史记录
  • with svn2git you can also split one SVN repository into multiple Git repositories easily使用svn2git您还可以轻松地将一个 SVN 存储库拆分为多个 Git 存储库
  • or combine multiple SVN repositories in the same SVN root into one Git repository easily或将同一 SVN 根目录中的多个 SVN 仓库轻松合并为一个 Git 仓库
  • the conversion is a gazillion times faster with the correct 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.

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