2

In my git repository I have two branches master and legacy. I have added the following .gitmodules file to my legacy branch. master branch does not have a .gitmodules file.However the git submodule is getting checked out in master branch. In the legacy branch nothing is getting checked out.

My .gitmodules file .

[submodule "build"]
    path = build
    url = git@git.gitlabs.com:Karthik.Sharma/build.git
    branch = 0.4

What am I doing wrong?

liv2hak
  • 14,472
  • 53
  • 157
  • 270
  • It depends on the sequence of operations you performed with git, which you should reveal as part of the question. Nothing is checked out on legacy is expected, as submodule only creates a link to a specific commit, or a branch. What happens to your master branch is unknown based on what you posted. – Lex Li Sep 03 '18 at 01:03
  • Submodules don't really use branches at all: the specific commit, if any, for a submodule is stored as a hash ID in the commit of the superproject. You extract the superproject's commit as usual (e.g., `git checkout `) and then instruct Git to wrench the submodule over to the subproject-commit-hash-ID saved in that superproject commit (`git submodule update`, or similar). The submodule repository is left in "detached HEAD" mode. – torek Sep 03 '18 at 02:49

1 Answers1

0

First, after adding the .gitmodules files, you should make a git submodule update --init in order to force the submodule to be checked out.

Second, check the nature of the build folder in the master branch.

git ls-files --stage | grep 160000

If you don't see build in the result, that means it is a regular folder (not a submodule).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250