2

How should I set up a git submodule to prevent a detached head?

When I check out my project, it has a submodule and the submodule also has a submodule. Now I want someone else to be able to checkout the root and just build without errors, but because of the detached head - lots of source doesn't get checked out and the build fails.

So the main project checks out fine, the submodule is detached, which then means the sub-sub module doesn't get checked out!

Any help please?

bandejapaisa
  • 26,576
  • 13
  • 94
  • 112
  • Not getting your reasoning: why is detached HEAD in submodule preventing subsubmodule to be checked out? And I don't know if detached HEAD in submodule can be prevented. AFAIK the main repo remembers only specific commit of submodules, not the "correct" branch the commit is meant to belong to. – Jokester Oct 22 '13 at 15:56
  • I'm not sure why it's preventing it. Maybe it's a Git Tower thing. But I check out main, submodule is checked out (detached), submodule has 3 submodules itself - each of which don't get checked out. – bandejapaisa Oct 22 '13 at 15:58
  • I have no experience with GitTower, but is [this post](http://stackoverflow.com/questions/1535524) related? – Jokester Oct 22 '13 at 15:59
  • Possibly. I think it's doing a --recursive already. I'll look into it further. – bandejapaisa Oct 22 '13 at 16:07

1 Answers1

1

Using git command-line, this would be done with git submodule update --recursive, maybe also with the --init option if the submodules haven't been initialized. See this answer

The Tower client may or may not have recursive options in its GUI, or a git command line feature, so this answer might only be halfway helpful.

Community
  • 1
  • 1
Nathan
  • 1,675
  • 17
  • 25