简体   繁体   中英

git clone --recursive - submodules on no branch

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"?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM