git submodule update fails with error on one machine but works on another machine

I also received this error using TortoiseGit while trying to update submodules that aren't in the index. That is, they exist in .gitmodules but have not been correctly added to the repository.

The solution is to manually re-add them using the paths specified in .gitmodules. You can use the TortoiseGit UI or run this on the command line for each module...

git submodule add <url> <path>

Re-adding a git submodule

(I realise this is probably not the solution for the original poster, but hopefully it helps others Googling this.)


This is likely because you or someone on your team has changes in your submodule that are unpublished (committed, but not pushed to the remote server). They then published the superproject with references to the git commit in the submodule which does not exist on the git server. So git is trying to pull down a specific submodule git commit ID that it can't find.

This would be the case if the changes are in a repository elsewhere on your machine or on another machine.

To resolve, go to that repository that references that commit and publish (push) the submodule changes to the server. Or change the submodule to point to a different commit ID.


In order to get new submodules into other repositories, I believe you need to run git submodule init once before starting to run git submodule update; this will register the new submodule from .gitmodules in .git/config.