1

I have a git module called 'production' and inside a couple of submodules. When I use the following command: git clone --recursive git@git_server:production it's clonning the 'production' module with the submodules. When I cd in one of the submodule and give the following command: git branch -a I get:

* (no branch)
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

The .gitmodules files contains:

[submodule "blabla"]
url = git@git_server:production/blabla
path = blabla
branch = refs/heads/master
...........................................

The question is: Why if I clone recursive the submodules are on the branch "(no branch)" and if I clone only the respective submodule is cloning directly on branch "master"? Is there any way to change the configuration that when I clone recursive to clone directly all the submodule in branch "master"?

Romulus
  • 1,150
  • 3
  • 16
  • 26

1 Answers1

1

Why if I clone recursive the submodules are on the branch "(no branch)"

The parent repo checkout the submodule directly on the SHA1 recorded by the gitlink (special entry in the index)

If you were to add a gitsubmodule update --recursive --remote (after your clone), then it would go ion the submodule, fetch and update the branch.

See also the submodule.$name.update config.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for answer! Unfortunately, when I give this command `git submodule update --recursive --remote` is doing nothing. The problem is thant git submodule doesn't have `--remote` flag. I am using git version 1.7.1 – Romulus Aug 14 '15 at 12:40