【问题标题】:git - submodule - checkout banch instead of hashesgit - 子模块 - 结帐分支而不是哈希
【发布时间】:2020-03-31 08:05:41
【问题描述】:

我有一个带有多个子模块的 git repo。

结帐时,我通常会这样做

git clone URL # without --recursive!

所以我有一个主存储库,已在 master 中签出

git checkout mybranchname_main_repo

现在我在其分支中签出了一个主存储库

git submodule update --init # now i checkout submodules because now they point to their supposed branch hash and not the master

现在在其分支中拥有主存储库,其子模块 (repos) 签出到最后提交的散列,该散列通常也在开发分支中,而不是主分支

我遇到的问题是所有子模块都检查最后提交的哈希值而不是分支/头。

是否有一个命令我可以添加一个额外的命令使子模块从它们在 HEAD 中的哈希值中检查分支?

类似:(警告,这是伪代码)

git submodule foreach checkout HEAD

【问题讨论】:

标签: git git-submodules


【解决方案1】:

将行 branch = <branchname> 直接添加到 .gitmodules 将允许 git submodule update --remote (有效地)更新到分支。您也可以使用git submodule add -b 添加此信息。

或者,git submodule foreach 存在,并在每个子模块中执行任意 shell 命令。因此,git submodule foreach 'git checkout HEAD' 也是检查每个子模块到HEAD 的完全有效的命令。

或者:Check this question which goes into a lot more detail with plenty of options.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    • 2018-05-29
    • 2015-08-16
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2014-02-12
    相关资源
    最近更新 更多