Git updates submodule with unaudited branch

I have been using git for a long time, but I stayed away from submodules, since I had no good reason to use them. However, I recently started a project that should explicitly use this git function.

However, every time I clone an entire project, the submodule ends with an unnamed branch. Here are the commands that I execute:

git clone <url to project> git submodule update --init <submodule> cd <submodule>; git branch 

and he prints:

 * (no branch) master 

I need to do more

 git checkout master 

Now my question is: is this standard behavior? If not, can you help me understand what I'm doing wrong?

thanks

+7
source share
1 answer

Unlike some other SCMs, commits in Git do not belong to any particular branch. The branch head looks like a bookmark for fixing. When you check the branch (i.e. .git/HEAD file contains a link to a branch) and you commit, Git moves this bookmark forward to indicate a new commit.

But this tracking behavior does not apply here. As you already know, a submodule is tied to a specific commit; it does not track branch branch. When you update a submodule, Git only checks for a specific commit. This means that .git/HEAD contains a commit hash, not a ref link.

There may be one or more branches of a branch pointing to this commit, but this kind of irrelevant. Only when HEAD contains a ref branch and not a commit hash will git branch show that you are on a branch.

+5
source

All Articles