1

Is it possible in GitHub to have a submodule in git be automatically linked to the submodule's branch's latest version without having to push the changes from git submodule update to the parent GitHub repo?

I know that a git submodule can track a remote branch (links below). And it makes sense that normally with code you will not want the behaviour I describe above.

The situation I'm trying to solve is one where there is one parent repo that is owned by somebody else. It contains standards/API information. Within that repo, there are links to different groups' API specs. These are independent of each other and do not need to have their versions coordinated. I control the git repo for my group's APIs. I would like that master repo to simply point to the latest version of my APIs without having to always request to the owners of the master repo to do a pull request.


Links, pointing to a question I'm not asking, but showing that yes I've done my research.

  1. git submodule tracking latest
  2. How can I specify a branch/tag when adding a Git submodule?
Mort
  • 3,379
  • 1
  • 25
  • 40
  • 2
    No, the point of a submodule is that it points to a commit. – jonrsharpe Aug 07 '19 at 15:05
  • @jonrsharpe can you think of some other way to deal with this situation? – Mort Aug 07 '19 at 15:06
  • Do not use the inner repository as a submodule. Clone it into the subdirectory but in the superproject add it to `.gitignore`. Now you can change the subrepository anyway you want, the superproject will ignore all changes. Of course anytime anyone needs to clone the superproject she has to clone the subrepo manually. You cannot have an independent subrepo that's automagically cloned at the same time. – phd Aug 07 '19 at 19:05
  • @phd Yeah, the goal is that we somehow be "part of" the superproject. That end-users of this data not have to be aware of where the APIs I supply come from they just get them when cloning the parent API repo. If people have to explicitly clone my repo it defeats the whole purpose. (There are actually to be a couple of layers of inclusion, but I left that out of the original question as that's just extra details to confuse the issue.) – Mort Aug 08 '19 at 13:25
  • But even submodules have to be cloned explicitly. You can use `git subtree` — it incorporates subtrees into the superproject but it has the same problem — when you import new commits you have to commit the change in the superproject. – phd Aug 08 '19 at 14:00
  • @phd `git clone --recurse-submodules`. Yes, you have to be aware of the existence of submodules, but that's all you have to know. – Mort Aug 08 '19 at 15:00
  • With subtree you don't even need `--recurse`. So go on with submodules or subtrees. Then you have to commit changes in the submodules or subtrees. You cannot have both at the same time. Either you have separate superproject and subprojects (and the users have to clone subprojects manually) or you use submodules/subtrees (and commit changes to the superproject). – phd Aug 08 '19 at 16:52

0 Answers0