Can submodules work with template repositories?

I’ve created a template repository(here) which has a git submodule folder in it. But when I try to use the template to create a repository(here), even though the .gitmodules file exists as expected, the submodule folder “scripts” from the template repository seemingly vanished somehow, and even if the derived repository is cloned, git commands like git submodule init or git submodule update don’t work.

I’m not really sure about what could be expected in this scenario as I couldn’t find any relevant docs. Ideally, I would expect the link to the submodule repository to be retained in the derived repository and the cloning process to initialize the submodules automatically, as otherwise, just cloning an ordinary repository and using it becomes an easier process than using a template repository.

So, is it even possible to get submodules to work with template repositories? If so, then I’d like to know how to do that. Thanks in advance!

2 Likes

Hi @CaptainIRS! :wave: Welcome to the Community!

At the moment submodules aren’t working with template repositories, sorry! In the longer term that functionality is intended to be added.

In the shorter term, we’re planning to edit our docs to make it clear that submodules currently aren’t working with templates.

Sorry for any frustration you may have experienced while trying to get them to work!

Why not spend the time making it work rather than spend time updating the docs saying it doesn’t? Also it’s been over a month and it doesn’t look like the docs have been updated to reflect this. This is all I can find: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-template-repository

How hard is it to add a line saying “note: submodules in template repositories do not currently work as expected”

1 Like