Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update commit hash in parent repo of submodule?

Tags:

git

I have a git repo with another repo as a submodule. The submodule is only used in this project. I commited change in the subrepo but the parent repo still references an older revision (Subproject commit 989471..... etc..)

How do I update the parent repo to point to the latest version of the subrepo. Is there a better way to do this so that they stay in sync as I change the subrepo?

like image 665
wtjones Avatar asked Sep 19 '25 18:09

wtjones


1 Answers

After commiting in the submodule, you change directories into the parent repository and do:

git add path/to/submodule

and commit the change. This will update the tracked commit ID. You'll have to do that for every (group of) commit in the submodule.

This is actually quite reasonable, as it's easily possible that the state of the parent directory depends on a certain state in the child repository (e. g. if bundling a library for a program; you might need a specific version for compilation to work), which is why it's smart to track the submodules commit in the parent repository instead of blindly checking out the HEAD of a specified branch.

like image 152
Jonas Schäfer Avatar answered Sep 21 '25 08:09

Jonas Schäfer