如何用另一个回购库替换一个git子模块? [英] How do I replace a git submodule with another repo?

查看:363
本文介绍了如何用另一个回购库替换一个git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



具体来说,我有一个子模块:

./ ExternalFrameworks / TestFramework 指向一个git仓库 git@github.com:userA / TestFramework.git

  • 现在我想指向 git@github.com:userB / TestFramework.git

    问题是,当我使用描述的方法删除子模块时, stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule\">这里,然后使用命令重新添加它

      git submodule add git@github.com:userB / TestFramework.git 

    我得到这个错误:

     'ExternalFrameworks / TestFramework'的git目录在远程本地找到, :
    origin git@github.com:userA / TestFramework.git
    如果您想重用此本地git目录而不是克隆ag ain from
    git@github.com:userB / TestFramework.git
    使用'--force'选项。如果本地git目录不是正确的repo
    ,或者您不确定这意味着用'--name'选项选择另一个名称。


    解决方案

    如果子模块的位置,那么你可以简单地:


    1. 修改你的 .gitmodule 文件以使用新的URL

    2. 运行 git submodule sync



    3. <更多完整的信息可以在其他地方找到:



      >

      How do I replace a git submodule with a different git repo?

      Specifically, I have a submodule:

      • located at ./ExternalFrameworks/TestFramework that points to a git repo git@github.com:userA/TestFramework.git
      • I'd like it to now point to git@github.com:userB/TestFramework.git.

      The problem is that when I delete the submodule with the method described here, then re-add it using the command

      git submodule add git@github.com:userB/TestFramework.git
      

      I get this error:

      A git directory for 'ExternalFrameworks/TestFramework' is found locally with remote(s):
        origin    git@github.com:userA/TestFramework.git
      If you want to reuse this local git directory instead of cloning again from
        git@github.com:userB/TestFramework.git
      use the '--force' option. If the local git directory is not the correct repo
      or you are unsure what this means choose another name with the '--name' option.
      

      解决方案

      If the location (URL) of the submodule has changed, then you can simply:

      1. Modify your .gitmodule file to use the new URL
      2. Run git submodule sync

      More complete info can be found elsewhere:

      这篇关于如何用另一个回购库替换一个git子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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