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

RE: fatal: could not reset submodule index

From
Antoine W. Campagna <awe@frontmatec.com>
Date
Jun 14, 2018, 18:19 UTC
Message-ID
<DB6PR0101MB2344D682511891E4E9528598D97D0@DB6PR0101MB2344.eurprd01.prod.exchangelabs.com>
On Wed, Jun 13, 2018 at 18:19, Antoine W. Campagna wrote:
> Here is the full reproduction instructions:
Newlines got mangled, making my message hard to read. Sorry.
Here is the corrected reproduction instructions:

# Create a repository mkdir main cd main git init touch main.txt git add main.txt git commit -a -m "Initial commit" cd ..

# Create a second repository mkdir sub cd sub git init touch sub.txt git add sub.txt git commit -a -m "Initial commit of repo sub" cd ..

# Add the second repository as submodule, on a separate branch cd main git branch with-submodule git checkout with-submodule git submodule add ../sub sub git commit -a -m "Add submodule"

# Set main repo back to master branch (without the submodule) git checkout master cd ..

# Make a clone and checkout the branch git clone main clone1 cd clone1 git checkout with-submodule # Submodule is not automatically updated (sub folder is empty) git submodule update --init --recursive # Now the submodule content is there # But I want to automatically update submodules when checking out a branch cd ..

# Trying again, adding --recursive during clone git clone --recursive main clone2 cd clone2 git checkout with-submodule # Submodule is still not automatically updated (sub folder is empty) git submodule update --init --recursive cd ..

# Trying again, adding --recurse-submodules during checkout git clone --recursive main clone3 cd clone3 git checkout --recurse-submodules with-submodule # Fails with these error messages : # fatal: not a git repository: ../.git/modules/sub # fatal: could not reset submodule index # It seems like Git tries to update the submodule but without having initialized the submodule cd ..

# Trying again with submodule.recurse git config --global submodule.recurse true git clone main clone4 cd clone4 git checkout with-submodule # Submodule is still not automatically updated (sub folder is empty) # It seems like submodule.recurse does not affect git clone

# Trying again with both submodule.recurse and --recursive git config --global submodule.recurse true git clone --recursive main clone5 cd clone5 git checkout with-submodule # Fails with these error messages : # fatal: not a git repository: ../.git/modules/sub # fatal: could not reset submodule index # Same issue as with "git checkout --recurse-submodules"

Next: Stefan Beller
Message 1 of 3 in “RE: fatal: could not reset submodule index”
  1. Antoine W. CampagnaJun 14, 2018
  2. Stefan BellerJun 15, 2018
  3. Antoine W. CampagnaJun 18, 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.