Search code examples
gitgit-submodules

How do I update a git submodule without checking it out


I am using a git submodule in a very usual way. The way how people typically update a submodule is by checking it out, pulling something in the submodule and then commiting outside.

Now, I typically don't develop those modules in the same place. For me it's more comfortable to develop those two modules in different places. How do I just tell my git project that one submodule has changed and is now at commit XYZ?

I think there's a chance that there's a setting somewhere in .git that I could modify.


Solution

  • you can do with this, as follows:

    git update-index --add --cacheinfo  mode,sha1,submodule_path
    
    

    the mode value can get from git ls-files --stage submodule_path

    git update-index reference