git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Issue in switching branches with different submodules

From
Cchristian.zitzmann@continental-corporation.com <christian.zitzmann@continental-corporation.com>
Date
Feb 22, 2018, 12:10 UTC
Message-ID
<OF65A78D43.F69630E3-ONC125823B.0057EE88-C125823C.0042D7B0@continental-corporation.com>

Hello, I've found an issue in git when working with submodules. My Project is set up using hundreds of components by submodules (and nested submodules), that are independent created in central development groups. Now it occurs that the structure of the submodules is changed over time.

E.g.
Project1(OldBranch)
  - ComponentX/SubComp1 -> ssh://Server/ComponentX/SubComp1
  - ComponentX/SubComp2 -> ssh://Server/ComponentX/SubComp2
  - ComponentX/SubComp2 -> ssh://Server/ComponentX/SubComp2
Project1(Masster)
  - ComponentX-> ssh://Server/ComponentX

There is both a repository for the old subcomponents, and for the new Component on the server.

When trying to switch between the branches all git commands are failing. It seems like most git commands are not creating the SubComponent submodules because the .git file from the Component is not deleted

A 'git submodule sync' fails with: fatal: Not a git repository: D:/Project1/ComponentX/../.git/modules/ComponentX

Looking into the folders I see: D:/Project1/.git/modules/ComponentX/SubComp1 D:/Project1/.git/modules/ComponentX/SubComp2 D:/Project1/.git/modules/ComponentX/SubComp3 D:/Project1/ComponentX/.git (file)

A 'git submodule update --init also fails with this folders Neither a forced checkout or a hard reset is working.

Similar errors can occur when switching between branches with a different number of components used as submodules vs. project specific content. As a result it happens that people are working with an incosistend state of the working directory.

My expectation would be that, when switching between branches/commits with 
a git checkout --recurse-submodules the branche including all submodules 
is checked out fully to exactly the state of the desired branch/commit
I.e the following usecases are an issue
- Deleted submodule
- Added submodule as replacement of local directory
- Changed remote location of submodule (One component is available from 
different providers having individual repositories)
- Restructured Component (see example)

Similar issues are existing when creating the new structure to commit it, but here the error is more obvious and people are manually deleting as much as required to get the new submodules correctly in.

Best regards
Christian Zitzmann
P HEV E SW SF PMT

Continental Automotive GmbH Siemensstrasse 12, 93055 Regensburg, Germany

Telefon/Phone: +49 941 790-7265
E-Mail: Christian.Zitzmann@continental-corporation.com
Next: Stefan Beller
Message 1 of 2 in “Issue in switching branches with different submodules”
  1. christian.zitzmann@continental-corporation.comFeb 22, 2018
  2. Stefan BellerFeb 24, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.