Home > database >  How to update the commit a git submodule points to if it does not point at the latest commit?
How to update the commit a git submodule points to if it does not point at the latest commit?

Time:04-18

I have forked a repo which has some submodules. In one of these submodules I want to make an update to the code and then update the superproject such that it points to the commit I made to fix the submodule. What I have done so far:

  • forked the superproject
  • forked the submodule
  • changed the .gitmodules file in the superproject to point to my fork
  • git submodule update --init in my local clone of the superproject
  • cd submodule and git checkout the commit the submodule is currently fixed to
  • updated the submodule with my changes and created a new branch (because I otherwise I cannot push it since the HEAD is detached)
  • commit and pushed the changes to the submodule into the new branch on remote
  • cd superproject and commit and push the changes here as well

Yet when I git clone superproject and do git submodule update --init in it, I still get 'old' commit without my changes. However, I require this to get the submodule version with my changes, because it is part of a script. Where did I make a mistake?

CodePudding user response:

The attempt listed above actually worked. The CMakeLists.txt in the subproject always checked out a hardcoded commit of the submodule, which cause the issue.

  • Related