Git Submodules checkout error

Hi,

after adding a submodule for the first time to one of our repositories, a build will fail with this error:

Error occurred while updating repository cache to changeset 625e61f2cc828051d0b6fb436f0ca7b4ac41d467 : Running ‘C:\Program Files\Git\cmd\git.exe’ with arguments “checkout --force --recurse-submodules 625e61f2cc828051d0b6fb436f0ca7b4ac41d467” failed with return code 128 and error output: "fatal: not a git repository: …/…/.git/modules/Libs/MyLib error: Submodule ‘Libs/MyLib’ could not be updated. error: Submodule ‘Libs/MyLib’ cannot checkout new HEAD. "

Any ideas?

Thomas

Hi Thomas,

The path in the error message suggests that the submodule url is pointing to a folder under the .git folder which I wouldn’t expect to be valid. Can you post (or send me) the contents of your .gitmodules file so we can see how the submodule is defined?

[submodule “Libs/MyLib”]
path = Libs/MyLib
url = http://…

I can create a (second) clone and checkout with no problems on my dev-machine. However, when i try to checkout in Continua’s repo using the commandline i will get the reported error.

I’m not sure what this url with triple dots is supposed to point to? Where is the submodule in relation to the main repository? How was the submodule defined and with which tool?

I’m not in the office today but will do some testing on this tomorrow. Meanwhile, try changing it from a relative url to a full url.

It’s a placeholder for the URL pointing to our git server. As it is confidential i did not publish it.

myproject/.git
myproject/Libs/MyLib

I created the submodule on a feature branch using SourceTree and pushed the branch to our TFS.

Hi Dave,

i got it working now, after having quite some pain with it :frowning:

Steps to fix

  • delete Continua’s repository
  • recreate Continua’s repository
    • the problem still persisted
  • with the commandline working on Continua’s repo directly and executing the following commands:
    git checkout --force 625e61f2cc828051d0b6fb436f0ca7b4ac41d467
    git submodule update --init --recursive Libs\MyLib
    git checkout --force --recurse-submodules 625e61f2cc828051d0b6fb436f0ca7b4ac41d467

Now it’s up and running. However, as i recreated Continua’s repo it affected all related configurations. I needed to edit all of them and fix errors caused by the recreation. I need to observe whether they are alright or causing other issues.

Summary

Introducing submodules for existing git repositories should not cause such pain. It should just work out of the box. As the problem arised for the newly created repo also, i consider the issue to be related to Continua’s way of handling submodules.

Thomas

Hi Dave,

the problem is back with every build. I need to apply the fix each time before i build. But i have more details about the issue. The submodules definition in ‘.git/config’ are missing. When executing the three git commands the following results are given.

  • git checkout --force [hash]
    This will succeed and give a valid status.
  • git submodule update --init --recursive Libs\MyLib
    This will copy the submodules definition from ‘…/.gitmodules’ to ‘.git/config’, fixing the missing entries.
  • git checkout --force --recurse-submodules [hash]
    This is the command that Continua is actually using. It will succeed now.

Thomas

Hi Thomas,

We’ve reproduced this now. Please bear with us while we work out a fix.

Hi Dave,

i am really glad you can reproduce this. Patiently waiting. :slight_smile:

Fixed in version v1.9.0.235