为什么git子模块在git checkout上不会自动更新? [英] Why is git submodule update not automatic on git checkout?

查看:1147
本文介绍了为什么git子模块在git checkout上不会自动更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 在什么情况下使用git checkout切换分支时,我会假设您大部分时间都想要更新您的子模块。您是否不是想要在切换后更新子模块?

  • 如果这是由git checkout自动完成的,会破坏什么?
  • ul>

    以示例更新:




    • 分支A在3852f1处具有子模块S

    • 分支B在fd72d7具有子模块S


    在分支A上,git checkout B将产生一个工作副本分支B的子模块S位于3852f1(带有修改的S)。 git子模块更新将在fd72d7处签出。

    解决方案

    我相信子模块不会自动更新符合开发目标Git的。 Git旨在以分布式模式工作,并且不会假定您甚至无法连接到非本地存储库,除非您明确告诉它。 Git不会自动刷新一个子模块会是这种想法的预期行为。



    就这么说,如果你知道你总是希望这些子模块被拉进来,你知道你永远不会从这些子模块分支到另一个本地仓库,如果你在结账后自动刷新它们,它不应该破坏任何东西。


    When switching branches with git checkout I would assume that most of the time you would want to update your submodules.

    • In what situation do you not want to update submodules after switching?
    • What would break if this was done automatically by git checkout?

    Updated with example:

    • Branch A has submodule S at 3852f1
    • Branch B has submodule S at fd72d7

    On branch A, git checkout B will result in a working copy of branch B with submodule S at 3852f1 (with a modified S). git submodule update will checkout S at fd72d7.

    解决方案

    I believe that the submodules not updating automatically is in line with the development goals of Git. Git is meant to work in a distributed mode and doesn't presume that you are even able to connect to a non-local repository unless you explicitly tell it to. Git not auto-refreshing a submodule would be the expected behavior when thought of that way.

    With that being said, if you know that you always want those sub-modules to be pulled in and you know that you would never branch off of those submodules to another local repository, then it shouldn't break anything if you automatically refreshed them after a checkout.

    这篇关于为什么git子模块在git checkout上不会自动更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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