gpt4 book ai didi

Git - 使用嵌套子模块?

转载 作者:太空狗 更新时间:2023-10-29 14:43:27 24 4
gpt4 key购买 nike

我有以下 git 存储库

  • 矢量
  • 随机
  • 字符串

String 依赖于 Vector,并将其添加为子模块。矢量子模块随机。 Random 没有依赖关系。

  • 模块:随机
  • 模块:向量
    • 子模块:随机
  • 模块:字符串
    • 子模块:Vector
      • 子模块:随机

当我更改 Vector 内的 Random 子模块内部的内容时,(不是实际模块 Random),它不会自动更新 Module: Random 或存在于别处的其他 Submodule Random

当我更改 Vector(模块)内部的内容时,它不会更新 String 中的 Vector。如果我访问 String 的存储库,并键入 git pull,它会声称所有内容都是最新的。如果我在 submodule Vectorcd 并键入 git pull,然后它才会实际更新我的 submodule Vector。最重要的是,它希望我将更改提交到 String 存储库,即使 String 内部没有任何更改。

如果我有一个包含 50 个子模块的存储库怎么办?我的子模块将不断地发生变化,我不想不仅每次想要触摸我的项目时都 pull ,而且还提交该 pull ,因为它是更改的子模块。必须有一种更简单的方法来做到这一点。

最佳答案

git pull options 中所述,你应该使用,来自 String (主要父 repo )a:

git pull --recurse-submodules=yes
git submodule update --recursive

On top of that it wants me to commit changes to the String repository, even though nothing has changed inside of String.

确定发生了一些变化:子模块 Vector 的 gitlink(repo 索引中的特殊条目)。

如果你不想每次都刷新 String 的内容,而只想做一个简单的常规 git pull,只做一次:

git config --global fetch.recurseSubmodules true

你可以automate the submodule update as a post-checkout hook .

类似地,只要您设置一次,来自 String 的简单 git push 也会推送任何更改的子模块:

git config --global push.recurseSubmodules true

关于Git - 使用嵌套子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43220718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com