为什么"git submodule update"会跳过一个子模块? [英] Why would 'git submodule update' skip a submodule?

查看:310
本文介绍了为什么"git submodule update"会跳过一个子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有单个子模块 sub/x 的git repo.(此子模块不包含其自己的任何子模块.)

I have a git repo with a single submodule sub/x. (This submodule does not contain any submodules of its own.)

在超级项目的仓库中, git status 的输出显示以下(未暂存的)修改

In the superproject's repo, the output of git status shows the following (unstaged) modification

modified:   sub/x (new commits)

如果我现在跑步

git submodule update

...在超级项目上,以下行被打印到终端(仅此而已):

...on the superproject, the following line gets printed to the terminal (and nothing more):

Skipping submodule 'sub/x'

此后,超级项目上的 git status 输出保持不变,如上所示.

After this, the output of git status on the superproject remains as shown above, unchanged.

(如果我向 git子模块更新命令添加-init ,则为同上.)

(Ditto if I add --init to the git submodule update command.)

问:如何确定为什么 git子模块更新[--init] 跳过 sub/x 子模块?

Q: How can I determine why git submodule update [--init] skips the sub/x submodule?

推荐答案

(注意:我只检查了最新的Git版本,并且子模块代码一直在进行更改,因此可能不是唯一的情况.但是这是在最新的Git中消息可以出现的唯一位置.)

(Note: I've only checked a very recent Git version, and the submodule code has been undergoing changes, so this might not be the only case. But it is the only place that message can occur in the latest Git.)

:当超级项目的 .git/config 中具有显式的 update = none 设置时,以下情况似乎适用.这比我在下面所做的猜测更有意义.这是 || 表达式的前半部分.我认为虽然没有 update = none 设置,但我们从下半年开始(未指定,type = NONE),仍然感到困惑.

Edit 2: it seems that the case below applies when the superproject's .git/config has an explicit update = none setting in it. That makes more sense than the guess I made below; it's the first half of the || expression here. I assumed there was no update = none setting though, and we were getting this from the second half (unspecified and type=NONE) and I still find that confusing.

(下面是原始答案)

此消息出现在 Git中子模块帮助程序代码:

        if (suc->update.type == SM_UPDATE_NONE
            || (suc->update.type == SM_UPDATE_UNSPECIFIED
                && update_type == SM_UPDATE_NONE)) {
                strbuf_addf(out, _("Skipping submodule '%s'"), displaypath);
                strbuf_addch(out, '\n');
                goto cleanup;
        }

当在超级项目的 .git/config 中为给定的子模块设置了 name .update 设置时,将触发此代码.更新类型未指定( git子模块更新,不带-checkout ).所以:

This code fires when there's no submodule.name.update setting set in the superproject's .git/config for the given submodule, and the update type is unspecified (git submodule update without --checkout). So:

git submodule update --checkout

将覆盖此设置,将子模块的更新设置配置为 checkout .我不明白为什么为什么这样的代码:文档说,默认设置为 checkout ,并且将实际设置设置为 checkout 时的行为有所不同,而默认设置为结帐,似乎与该声明不符.

would override this, as would configuring the submodule's update setting to checkout. I don't understand why the code is this way: the documentation says that the default is checkout, and behaving differently with the actual setting set to checkout, vs defaulting to checkout, does not seem to match this claim.

这篇关于为什么"git submodule update"会跳过一个子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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