问题描述
我已经引用了以下内容: Git子模块头'reference不是树的错误
I've reference this: Git submodule head 'reference is not a tree' error
这是 git子模块跟踪最新
可能我的问题略有不同.(我假设它是相同的,但没有做正确的事...)
Possibly my problem is slightly different. (I'm assuming its the same but not doing something right...)
我希望自己的git设置能够运行:
I want my git setup such that if I run:
git clone -b master --recursive /path/to/main/repo.git
子模块 应该始终针对主"进行克隆
否则,在许多情况下,所引用的提交不存在(子模块的分支)或已过时",从而导致克隆失败并显示错误:
Otherwise, in many cases the referenced commit doesn't exist (The branch of the submodule) or are "out of date" causing the clone to fail with error:
fatal: reference is not a tree
我试图设置主存储库以使用子模块主模块:
I've tried to setup the main repository to take the submodule master:
git submodule add -b master /path/to/submodule.git
但是在克隆主仓库时:
git clone -b master --recursive /path/to/main/repo.git
所引用的子模块提交不存在(未按预期使用master)
The submodule commit referenced doesn't exist (not taking master as expected)
推荐答案
由于子模块从未针对分支签出.
总是在 gitlink ()
As submodule is never checked out against a branch.
It is always checked out at the SHA1 recorded by the gitlink (special entry in the index)
您可以做的是:
- 确保子模块设置为遵循
master
分支
请参阅"如何使现有子模块跟踪分支" - 执行
git子模块更新--remote --recursive
,以确保每个子模块均可获取并根据其各自的master
分支进行更新.
- making sure the submodule is set to follow the
master
branch
See "How to make an existing submodule track a branch" - do a
git submodule update --remote --recursive
to make sure each submodule fetch and update themselves against their respectivemaster
branch.
这篇关于如何设置子模块,以便git clone --recursive始终掌握子模块的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!