【问题标题】:How to read .git/index file for submodules如何读取子模块的 .git/index 文件
【发布时间】:2023-03-03 14:20:01
【问题描述】:

我有 test 文件夹,我在其中添加了一个子模块,之后我从文件夹中手动删除了 .gitmodules 文件,然后再次想要添加子模块,但如果我有多个子模块,则会遇到类似 'test' already exists in the index 的错误子模块并且它们没有.gitmodule 文件我们将如何识别它们是否是子模块?如果这个问题很愚蠢,请抱歉,因为我对 git 很陌生。我有人建议link,但无法发出识别此问题的命令。有人可以帮我吗?

【问题讨论】:

    标签: git git-submodules git-subtree


    【解决方案1】:

    您有一个test 文件夹,但这是您的顶级 git 存储库吗?如果有 test/.git 文件夹,那么它就是一个 git repo。

    您可能不应该删除 test/.gitmodules 文件 - 您想在这里完成什么?

    'test' already exists in the index - 事实上,如果你再次尝试添加相同的子模块,你可能会得到类似的错误。

    I have multiple submodules and they don't have .gitmodule file - how will we identify that they are submodules or not? - 子模块不知道它们是子模块。当您更改它们时,您会看到子模块在顶级/超级项目的 git 状态中是“脏的”。

    如果你使用 git subrepo,这对新手来说更容易,你会注意到每个“子 repo”里面都有某种.gitrepo 文件,表明它是一个 subrepo。

    如果您是 git 新手,请查看 git subrepo,git 子模块不适合胆小的人。 https://github.com/ingydotnet/git-subrepo

    我建议从头开始 使用新的 git 存储库。如果您在项目中取消推送更改,请将它们复制粘贴到新/新克隆的存储库中。然后仔细按照 git-subrepo 的设置说明进行操作。

    【讨论】:

      猜你喜欢
      • 2012-04-20
      • 2018-03-13
      • 2019-06-03
      • 2015-06-27
      • 1970-01-01
      • 2021-01-23
      • 2019-06-22
      • 2010-11-28
      相关资源
      最近更新 更多