2

I've reference this: Git submodule head 'reference is not a tree' error

And this: git submodule tracking latest

Possibly my problem is slightly different. (I'm assuming its the same but not doing something right...)

I want my git setup such that if I run:

git clone -b master --recursive /path/to/main/repo.git

the submodules should always be cloned against "master"

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

But when cloning the main repo:

git clone -b master --recursive /path/to/main/repo.git

The submodule commit referenced doesn't exist (not taking master as expected)

Community
  • 1
  • 1
Avba
  • 14,822
  • 20
  • 92
  • 192

1 Answers1

3

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)

What you can do is:

  • 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.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250