简体   繁体   中英

Why is git clone --recursive cloning detached submodules

I've added some submodules to my git repo using the following (note the -b switch) :

git submodule add -b dev-master git@github.com:OurCompany/The_Submodule.git

and when cloning the module recursively with

git clone --recursive -b dev-master git@github.com:OurCompany/The_Repository.git

the submodules get cloned, but running

git branch

indicates that the submodule is in a detached state.

I can fix by checking out the submodule with

git checkout dev-master

but isn't there a way to clone recursively with the submodules checked out on the tracked dev-master branch I added in the git submodule add step, instead of giving me a detached branch?

The parent project does not track the tags (ie master or dev-master ). It only pins the sha1-ids of each submodule.

If you now want to have all submodules point to the current master (which might not be the one you expected), you can run:

git submodule foreach git checkout dev-master

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