通过清理将SVN迁移到git [英] Migrate SVN to git with cleanup

查看:157
本文介绍了通过清理将SVN迁移到git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的项目从SVN迁移到git,但我想要清除所有文件的历史记录,并基本消除分支。我有几个问题:


  • 一些模块(子目录),其中创建,处理并稍后放弃。我不希望它们出现在我的历史记录中。
  • 有些代码是在存储库中的不同位置开发的(不是此项目的一个分支),然后复制svn。即/ otherproject / trunk / foo被合并到/ myproject / trunk / bar中。它应该看起来像是从一开始就在那里开发的。

  • 一旦我在分支中发生了大量返工,我们决定从trunk重新移植到该分支,然后将分支移动到trunk (用树枝替换树干)。它应该看起来像它的化身树干。



当我使用svn2git我结束了各种分支(一些导入来自另一个项目),而树干的历史并不像它可能的那样有用。我想要的是基本上每个单个文件(或更清晰的目录)的历史记录将在剥离发生的所有移动时被恢复。如果其他分支仍然相关的不会被保留下来,这并不重要。



与此相关的一个问题是:从svn到git,移动中继线



我会很乐意提供任何建议,例如在迁移之前做一些神奇的SVN,在迁移后有一个聪明的迁移方式或者git清理。

> 1像#1这样的简单情况可以通过 svndumpfilter



2更复杂的情况可以通过重写历史来解决。虽然你应该明白,这是一个复杂而容易出错的过程。

因此,基本上你应该:
$ b $ <$> $ $使用Python + svndump $ b $ li lib - 删除节点,替换节点路径,重新排列修订等。
  • 加载转储
  • 比较(如果需要)使用新的旧版本库确保历史记录不会丢失

  • >

    如果需要,我可以提供python脚本示例。


    I want to migrate my project from SVN to git but I would like to have a clean history of all files and basically get rid of branches. A few of the issues I have:

    • Some modules (subdirectories) where created, worked on and later discarded. I don't want them in my history.
    • Some code was developed at different places in the repository (not a branch of this project) and then svn copy'ed. i.e. /otherproject/trunk/foo was incorporated into /myproject/trunk/bar. It should look like it was developed there from the start.
    • Once I had a huge rework happen in a branch so we decided to backport from trunk to that branch and then move the branch to trunk (replace trunk with the branch). It should look like it was trunk since its incarnation.

    When I use svn2git I end up with all kinds of branches (some "imported" from the other project) and the history of the trunk is not as helpful as it could be. What I would like to have instead is basically have the history of each single file (or directory which is cleaner) to be recovered while stripping all the moving around that took place. If the other branches that are still relevant are not preserved by this it doesn't particularly matter.

    A related question to this is: From svn to git, with a moved trunk

    I would be happy for any suggestions, e.g. do some magic in SVN before the migration, have a clever way of migration or "clean up" in git after the migration.

    解决方案

    1 Simple cases like #1 can be filtered by svndumpfilter

    2 More complex cases can be solved by rewriting history. Though you should understand that this is complex and error prone process.

    So, basically you should:

    • make dump
    • process it with Python + svndump lib as you want - remove nodes, replace nodes paths, rearrange revisions and so on.
    • load dump
    • compare (if need) old repository with new to be sure that history is not lost

    If you want, I can provide python script examples.

    这篇关于通过清理将SVN迁移到git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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