如何设置子模块,以便git clone --recursive始终掌握子模块的权限 [英] How to setup submodule so that git clone --recursive always takes master of submodule

查看:111
本文介绍了如何设置子模块,以便git clone --recursive始终掌握子模块的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经引用了以下内容: 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)

您可以做的是:

  • 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 respective master branch.

这篇关于如何设置子模块,以便git clone --recursive始终掌握子模块的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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