Let’s say you have a submodule that you want to change, but the submodule itself is huge. You might not want another copy of it, so you’re holding off on running git submodule update --init
. Internally in your repo, Git records the commit that the submodule points to. If you have the exact commit ID, you can run this command to adjust it points to in the index (substituting the hash for the commit ID you want to change it to, and of course, the path to the submodule):
git update-index --add --cacheinfo 160000,4435a55c4c352d5c703cab322c208ca4dce14ae8,submodule_name_here
This is added to the index, so you’ll have to commit your change as normal.