Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

Unable to checkout git submodule path

I have a problem when working with git submodules.

Whenever i receive a new submodule reference from the upstream repository, executing git submodule update gives the following result:

fatal: reference is not a tree: dd208d46ecdd1ac0d2b2594a610fe4c9150fece1
Unable to checkout 'dd208d46ecdd1ac0d2b2594a610fe4c9150fece1' in submodule path 'submodule/path'

It is important to note that the submodule has several remotes, of which the upstream remote should be used to update the submodule reference tree. I'm guessing that my problem is there, but i am not sure.

My setup is the following:

Git project

Remotes:

  1. origin (my git fork)
  2. upstream (project repo)

Submodule "module", has remotes:

  1. origin (my git fork)
  2. upstream (project repo)

Does anyone know what is causing my problem?

question from:https://stackoverflow.com/questions/14768509/unable-to-checkout-git-submodule-path

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When doing git submodule update, git tries to checkout the commit/tree which is saved in the super project (in your example, the one with commit id dd208d4...)

I think you get the error because within the submodule there no such object present. You have to make sure that it is there. Usually that means that you have to fetch/pull it from a remote first.

Probably you have to

git submodule foreach git fetch
git submodule update

or maybe

git fetch --recurse-submodules

Assuming, that the submodule is configured, so that it can fetch the missing commit from the remote origin. In the end, you must know, from where you can fetch the missing commit and you have to get it.

You could check, whether you have dd208d4... by doing something like:

cd ./module
git log dd208d46ecdd1ac0d2b2594a610fe4c9150fece1
git cat-file -p dd208d46ecdd1ac0d2b2594a610fe4c9150fece1
git ls-tree dd208d46ecdd1ac0d2b2594a610fe4c9150fece1

One possible cause for such a problem is, that the one who published the new commit from the super module, did not publish the necessary commits from the submodule. He has to publish the commits from the submodule first.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...