【发布时间】:2021-03-04 22:37:10
【问题描述】:
我有一个名为 anecdotes 的元 repo,它有两个子模块 - 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 操作中,尝试从轶事回购中进行部署。首先,我检查轶事回购 - 通过这样做,检查回购和子模块的操作(获取和克隆它) 此时 - global-sync & utils repo 已正确签出(意味着 - 因为它已在 necdotes 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" 只列出开发分支
有什么想法吗?
- 我删除了轶事中的 utils 目录并克隆了它 - 问题仍然存在。
- 尝试在本地更新子模块 - 成功。
【问题讨论】:
-
如果“git 操作”是指“gitHUB 操作”,那么他们可能正在为其子模块使用浅和/或单分支克隆。确保他们不这样做(通过他们提供默认这样做的任何配置项)。
-
请不要编辑您的问题的答案。您可以在下面发布您自己问题的完整答案。此外,如前所述,请确保使用正确的术语。 Git 和 GitHub 是不同的东西,提供不同的功能(有时名称冲突)
标签: git git-submodules