0

I have a parent repository named 'A' that contain a submodule 'B' When I clone 'A' i got 'B' detached HEAD to a specific commit.

My clone command is:

git clone --recurse-submodules https://github.com/.../A.git

After that i am enter to 'A' folder:

cd A

I am automatically on 'develop' branch - Great!

When I am enter to my submodule folder:

cd B

I am automatically got (HEAD detached at 6dce2e1) - WHY ?!?! I want to be automatically on develop also here.

I have read all previous question - nothing help!

What i have tried:

  1. delete submodule -> commit -> add again with write implicit develop branch name.

  2. checkout B repo to develop and commit it in A repo

I have already tried this post: Why is my GIT Submodule HEAD detached from master?

Also, tries this: How can I specify a branch/tag when adding a Git submodule?

It is just do not solve my issue! When i am cloning to new folder the issue is come back!

But it is simply not solved my issue.

How can i solve it? and why it is suddenly happened?

9
  • No, I have already tries this answer and this is not solved my issue Commented May 29, 2019 at 9:49
  • The submodule is supposed to be detached. That's not an error, that's the way submodules are intended to be used. I added another old question whose accepted answer is, I think, better. Commented May 29, 2019 at 16:36
  • Thank you for your answer but this issue was not shown before. it is suddenly happened. I want to clone my 'A' and 'B' with develop branch automatically. not detached head. Commented May 30, 2019 at 7:32
  • You can't: cloning a new repository with recursive submodule cloning always puts the submodules in detached HEAD mode. (If you have a counterexample, include details—a minimal reproducible example—in your question.) Commented May 30, 2019 at 7:34
  • @torek Tnx again, but it is possible for sure. if you will create two new repo's and declare the submodule from scratch everything will be ok Commented May 30, 2019 at 8:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.