Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git command to force a particular commit in a submodule

Is there a Git command to force a specific submodule/main module relationship or do I have to manually edit a file in the .git directory?

For example, my main program uses a library common to many projects, but I need to have a particular commit in the library tied to my main program.

I.e., I have been using submodules naively and the relationships are messed up, and I want to fix them.

like image 218
Walt Howard Avatar asked Feb 26 '26 12:02

Walt Howard


1 Answers

By definition, a submodule is a way to record a specific SHA1 as a gitlink entry in the index of the parent repository.

If somehow the submodule doesn't reflect the right SHA1, all you have to do is checkout the appropriate SHA1, go back to the parent repo, add and commit: that will record the new desired state of the submodule.

like image 80
VonC Avatar answered Feb 28 '26 02:02

VonC