1

Ive created one repo out of two small repos which are now submodules. In this Master Repo, I can change these submodules and commit them to a PR from the Master Repo, however in Github, I am unable to actually open the submodules in Github. They are hidden behind an unclickable file with the submodule repo # name and the folder icon has a little white arrow pointing right [see image]

enter image description here

This is the folder structure. Each submodule ofc has its own remote added pointing to the original repo that it came from.

Master Repo ->
  -submodule repo 1 
  -submodule repo 2 

How can I get github to actually show the contents of these submodules in things like pull request reviews and such?

Ian Steffy
  • 1,234
  • 3
  • 18
  • 45

1 Answers1

3

If I look at my own repository github.com/VonC/git-cred, my submodule batcolors @ 83bcef4 is clickable.

It is composed of:

In your case, check if:

  • the submodule and its exact path are declared in your own .gitmodules file
  • if the associated URL is one GitHub can interpret.

How can I get GitHub to actually show the contents of these submodules in things like pull request reviews and such?

That is not supported with a submodule approach (reference to a sub-repository).

A subtree approach would:

  • preserve the Git history of the smaller repository before being "integrated" into the bigger one
  • show diffs during a pull request.

https://wac-cdn.atlassian.com/dam/jcr:f5fcef58-5b93-4ff4-b9a1-3f721d29ead8/BeforeAfterGitSubtreeDiagram.png?cdnVersion=637

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I think the OP is trying to view the diffs of his submodule(s) *in the pull request view*. afaik it is not possible in the web GUI at the moment, but perhaps you know better – LeGEC Nov 18 '22 at 08:01
  • While this solution does allow me to open the submodules, it merely redirects me to the submodule's repo url upon opening. What I want is that the submodule/ smaller repo is a part of the parent repo but still maintains the git history from before the two smaller repos were merged. For example, if i deleted www.github.com/repo1 and repo2, the parent repo and its sub-repos would not be affected. – Ian Steffy Nov 18 '22 at 08:58
  • 1
    @IanSteffy "What I want is that the submodule/ smaller repo is a part of the parent repo but still maintains the git history from before the two smaller repos were merged.": that what a submodule is: its own Git history is maintained. There is no "merge". – VonC Nov 18 '22 at 09:09
  • 1
    @IanSteffy Maybe a subtree approach would be a better fit in your case? See my edited answer. – VonC Nov 18 '22 at 09:22
  • @VonC This is what I was looking for. Thanks and enjoy the bounty, bounty hunter. – Ian Steffy Nov 18 '22 at 14:21