首页 > 解决方案 > git子模块更新失败

问题描述

我有元 repo,名为 anecdotes,它有两个子模块 - utils 和 global-sync。全局同步中也有 utils 子模块。在轶事回购中有 .gitmodules 文件,内容如下:

[submodule "globals-sync"]
    path = globals-sync
    url = https://github.com/organization/globals-sync.git
    branch = master
[submodule "utils"]
    path = utils
    url = https://github.com/organization/utils.git
    branch = master

全局同步 .gitmodules 文件内容为:

[submodule "utils"]
        path = utils
        url = https://github.com/organization/utils.git

utils repo 的默认分支是 develop,global-sync repo 的默认分支是 master(正如我所说,global-sync repo 包含 utils 子模块)。

git版本是2.30

现在 - 描述问题: 在 github 操作中,尝试从轶事 repo 进行部署。首先,我检查轶事回购 - 通过这样做,此时检查回购和子模块(获取和克隆它)的操作 - 正确检查了全局同步和实用程序回购(意味着 - 因为它正在轶事回购中提交)

现在,我想将子模块更新为最新的提交(在远程)所以我运行:

git submodule update --remote

立即失败并出现以下错误:

fatal: Needed a single revision
Unable to find current origin/master revision in submodule path 'utils'

在阅读了很多类似的问题后,我可以隔离问题:: here

通过 cd 到 utils 目录并获取有关 repo 的信息,我看到“master”分支不存在:“git branch -a”仅列出了开发分支

有任何想法吗?

标签: gitgit-submodules

解决方案


问题是我没有在 yaml 文件中明确设置 fetch-depth。默认 fetch-depth 为 1,只需添加 0 值(表示全部),然后我就可以看到所有分支。使用:actions/checkout@v2 with:token:${{ secrets.GITHUB }} 子模块:'recursive


推荐阅读