0

I have set up a git submodule in a git repository.

On pushing changes to this submodule, I can see all the files added to this submodule in local branch. However, I don't see these files in the submodule in the remote branch. All I see in the remote branch is a submodule file with a <guid> as content. I see all the commits correctly.

Is this expected?

If that's the case, I have a YAML file within this submodule to be used for Build/Release. Is it possible to create a Build/Release using the YAML file within the submodule because this file is not visible in remote branch?

prosoitos
  • 6,679
  • 5
  • 27
  • 41
user989988
  • 3,006
  • 7
  • 44
  • 91
  • Besides the general submodule confusion, note that Git itself never looks at YAML. There are a few files stored in commits that *do* affect Git's operation: `.gitignore`, `.gitattributes`, and of course for submodules, `.gitmodules`, but none of these are YAML-encoded. YAML is therefore entirely irrelevant to Git. There are build systems that use YAML directives, but that's not a Git thing, that's a thing in the build system. – torek Oct 29 '20 at 02:53

1 Answers1

0

The content of the submodule is not part of the parent repository: the submodule is a Git repository of its own and the content of the submodule is part of that repository. So what you are seeing is expected.

From the Pro Git book chapter on submodules:

Although [the submodule] is a subdirectory in your working directory, Git sees it as a submodule and doesn’t track its contents when you’re not in that directory. Instead, Git sees it as a particular commit from that repository.

"Git doesn't track its content" has, as a consequence, that the content is not pushed to your remote (which is why, in your remote, you do not see the content of the submodule).

"Instead, Git sees it as a particular commit from that repository." Indeed, if, for instance, you use GitHub as your remote and if you look at the submodule within the parent project, instead of the submodule content, you will see a link to the commit of the submodule repository that was last pushed to the parent project.

Now, to answer your second question:

Some particular architectures can use the files within submodules. The static site generator Hugo for instance allows you to have a theme as a submodule of your site and the content of the theme (including YAML files) is used by the parent project.

On the other hand, in other cases which seem closer to your own situation, this does not seem to work.

So I guess it depends on your project architecture, but a git submodule is probably not the best option for you.

prosoitos
  • 6,679
  • 5
  • 27
  • 41