如何修改git存储库以在所有过去的修订版本中添加子模块? [英] How to modify git repository to add submodules in ALL the past revisions?

查看:266
本文介绍了如何修改git存储库以在所有过去的修订版本中添加子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git svn-clone 将我的SVN存储库与标签成功迁移到Git。但是, git svn-clone 不会迁移 svn:externals 。因此,我决定使用 git filter-branch



修改分支树。对于 svn :externals ,首先我为每个svn:externals创建了一个单独的Git存储库,然后尝试使用以下内容,但它无效。

  $ git filter-branch --tree-filtergit submodule add git@github.com:myAcc / mySubmodule.git mySubmoduleHEAD 
Rewrite a013a219e4294d4ee66b323cf1db9c170d90130a(1/4)致命的:工作树'。'已经存在。
将'git@github.com:myAcc / mySubmodule.git'克隆到子模块路径'common'失败
树过滤器失败:git submodule add git@github.com:myAcc / mySubmodule.git mySubmodule
rm:无法删除`c:/myRepo/.git-rewrite/revs':权限被拒绝
rm:无法删除目录`c:/myRepo/.git-rewrite':目录不为空

任何想法如何实现?

解决方案

我认为你可以这样做,但也可以在清理方式:
$ b $ ol

  • 创建临时空的git存储库
  • 添加您的 svn :外部 s作为子模块并提交;注意此提交的SHA名称

  • 进入旧的存储库

  • git fetch from临时资源库

  • git rebase<临时资源库中唯一提交的SHA>


  • I migrated my SVN repository successfully with Tags into Git using git svn-clone. However, git svn-clone does not migrate svn:externals. Hence, I decided to modify branch tree using git filter-branch.

    For svn:externals, first I created a separate Git repository for each svn:externals and then I tried using the following, but it didn't work.

    $ git filter-branch --tree-filter "git submodule add git@github.com:myAcc/mySubmodule.git mySubmodule" HEAD
    Rewrite a013a219e4294d4ee66b323cf1db9c170d90130a (1/4)fatal: working tree '.' already exists.
    Clone of 'git@github.com:myAcc/mySubmodule.git' into submodule path 'common' failed
    tree filter failed: git submodule add git@github.com:myAcc/mySubmodule.git mySubmodule
    rm: cannot remove `c:/myRepo/.git-rewrite/revs': Permission denied
    rm: cannot remove directory `c:/myRepo/.git-rewrite': Directory not empty
    

    Any idea how to accomplish this? Thanks a lot in advance.

    解决方案

    I think you could do it this way, but it may be possible to do it in a cleaner way:

    1. Create temporary empty git repository
    2. Add your svn:externals to it as submodules and commit; note the SHA name of this commit
    3. Go into your old repository
    4. git fetch from the temporary repository
    5. git rebase <SHA of the only commit in the temporary repository>

    这篇关于如何修改git存储库以在所有过去的修订版本中添加子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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