Source:
<code>private void connectProject(Entry<IProject, File> entry, MultiStatus ms, IProgressMonitor monitor) throws CoreException { IProject project = entry.getKey(); String taskName = NLS.bind( CoreText.ConnectProviderOperation_ConnectingProject, project.getName()); SubMonitor subMon = SubMonitor.convert(monitor, taskName, 100); if (GitTraceLocation.CORE.isActive()) { GitTraceLocation.getTrace() .trace(GitTraceLocation.CORE.getLocation(), taskName); } RepositoryFinder finder = new RepositoryFinder(project); <START> finder.setFindInChildren(true); <END> Collection<RepositoryMapping> repos = finder.find(subMon.newChild(50)); if (repos.isEmpty()) { ms.add(Activator.error(NLS.bind( CoreText.ConnectProviderOperation_NoRepositoriesError, project.getName()), null)); return; } GitProjectData projectData = new GitProjectData(project); try { projectData.setRepositoryMappings(repos); projectData.store(); GitProjectData.add(project, projectData); } catch (CoreException ce) { ms.add(ce.getStatus()); deleteGitProvider(ms, project); return; } catch (RuntimeException ce) { ms.add(Activator.error(ce.getMessage(), ce)); deleteGitProvider(ms, project); return; } RepositoryProvider.map(project, GitProvider.ID); if (refreshResources) { project.refreshLocal(IResource.DEPTH_INFINITE, subMon.newChild(40)); } else { subMon.worked(40); } autoIgnoreDerivedResources(project, subMon.newChild(10)); }</code><technical_language>I that, too, work reliably for submodules in subfolders. reason is ProjectUtil asynchronous refresh a newly imported project, this time run (or progressed deep enough), RepositoryFinder find repos in folders. a synchronous refresh in ProjectUtil is a good idea; afraid lead unresponsive UI a large project projects imported. In change 67186, submodules picked in GitProjectData resource change events triggered refresh line 143</technical_language>

Target:
private void connectProject(Entry<IProject, File> entry, MultiStatus ms, IProgressMonitor monitor) throws CoreException { IProject project = entry.getKey(); String taskName = NLS.bind( CoreText.ConnectProviderOperation_ConnectingProject, project.getName()); SubMonitor subMon = SubMonitor.convert(monitor, taskName, 100); if (GitTraceLocation.CORE.isActive()) { GitTraceLocation.getTrace() .trace(GitTraceLocation.CORE.getLocation(), taskName); } RepositoryFinder finder = new RepositoryFinder(project); finder.setFindInChildren(false); Collection<RepositoryMapping> repos = finder.find(subMon.newChild(50)); if (repos.isEmpty()) { ms.add(Activator.error(NLS.bind( CoreText.ConnectProviderOperation_NoRepositoriesError, project.getName()), null)); return; } RepositoryMapping actualMapping = findActualRepository(repos, entry.getValue()); if (actualMapping == null) { ms.add(Activator.error(NLS.bind( CoreText.ConnectProviderOperation_UnexpectedRepositoryError, new Object[] { project.getName(), entry.getValue().toString(), repos.toString() }), null)); return; } GitProjectData projectData = new GitProjectData(project); try { projectData.setRepositoryMappings(Arrays.asList(actualMapping)); projectData.store(); GitProjectData.add(project, projectData); } catch (CoreException ce) { ms.add(ce.getStatus()); deleteGitProvider(ms, project); return; } catch (RuntimeException ce) { ms.add(Activator.error(ce.getMessage(), ce)); deleteGitProvider(ms, project); return; } RepositoryProvider.map(project, GitProvider.ID); if (refreshResources) { project.refreshLocal(IResource.DEPTH_INFINITE, subMon.newChild(40)); } else { subMon.worked(40); } autoIgnoreDerivedResources(project, subMon.newChild(10)); }