threads / discuss / 51594

Suggestion: git clone should warn if repository has submodules

Subject: Suggestion: git clone should warn if repository has submodules

## tl;dr

3 messages between Aug 6, 2019 and Aug 6, 2019.

replies: 2people: 3as markdown or json

Jason Sewall· Aug 6, 2019, 14:03 UTC · lore

Submodules are great, and I used them at work. The problem is, people wind up cloning my repos without --recursive and then nothing works for them, because the submodules weren't populated and those ultimately are needed to build my code.

I can see why --recursive isn't the default for git clone; you don't want to just blindly follow whatever urls are in .gitmodules without the user being aware of the possibility. That said, folks that are not familiar with submodules (which seems to be most of the people I work with!) wind up confused by this and don't know how to fix it.

While the burden is on the user and should remain so, it seems like having git print out a message after cloning to the effect of "there are submodules that are not populated, maybe you should look at them" would go a long way to eliminating confusion for newer users. Yes, I have put some documentation in my project that users should fetch the submodules, but if possible, I'd like lower the number of times I have to suggest that people RTFM.

Alternatively, is it preferable that I have my build system look at the submodules and inform the user more helpfully? I'm curious to know what, if any, is the recommended procedure.

Cheers, Jason

Mateusz Loskot· Aug 6, 2019, 15:54 UTC · re: Jason Sewall · lore

Re: Suggestion: git clone should warn if repository has submodules

On Tue, 6 Aug 2019 at 16:04, Jason Sewall <jasonsewall@gmail.com> wrote:
Show 5 quoted lines
>
> Submodules are great, and I used them at work. The problem is, people
> wind up cloning my repos without --recursive and then nothing works
> for them, because  the submodules weren't populated and those
> ultimately are needed to build my code.

What you need is a simple document for your team that outlines the common Git workflow or README.md in root directory of your repositories with fat heading:

## Clone

``` git clone --recursive ... ```

A team in another company may require non-recursive clones by default and warnings from git may be quite annoying. Given the fact there is not one but may valid "my way"-s available, acceptable and supported by Git, I think, babysitting behaviour is not quite aligned with its philosophy, is it?

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Michal Suchánek· Aug 6, 2019, 15:58 UTC · re: Mateusz Loskot · lore

Re: Suggestion: git clone should warn if repository has submodules

On Tue, 6 Aug 2019 17:54:20 +0200 Mateusz Loskot <mateusz@loskot.net> wrote:

Show 22 quoted lines
> On Tue, 6 Aug 2019 at 16:04, Jason Sewall <jasonsewall@gmail.com> wrote:
> >
> > Submodules are great, and I used them at work. The problem is, people
> > wind up cloning my repos without --recursive and then nothing works
> > for them, because  the submodules weren't populated and those
> > ultimately are needed to build my code.  
> 
> What you need is a simple document for your team that outlines the common
> Git workflow or README.md in root directory of your repositories with
> fat heading:
> 
> ## Clone
> 
> ```
> git clone --recursive ...
> ```
> 
> 
> A team in another company may require non-recursive clones by default
> and warnings from git may be quite annoying. Given the fact there is not
> one but may valid "my way"-s available, acceptable and supported by Git,
> I think, babysitting behaviour is not quite aligned with its philosophy, is it?

It has warnings that you can disable globally or per-repository in configuration to fit your workflow.

Thanks
Michal

← back to recent threads