Reputation: 614
I have a project that has a submodule inside. I want to be able to clone the parent project with --recursive
and get the submodule at a specific hash for that submodule. The specific hash is not the head of any branch, it is a specific commit.
From a svn perspective to peg the external to a specific revision.
I tried to add the submodule to a branch and checkout the required hash, but when I wanted to commit the change it kept the initial hash from the add.
Upvotes: 7
Views: 11806
Reputation: 34012
Basically it is the Git default that a submodule is pegged to a specific hash (i.e., the checkout commit of the submodule) with a commit in the super project (however, the submodule is not automatically updated when you change your parent repository by default - to do this manually TortoiseGit offers the "Submodule update" feature or you can configure submodule.recurse
).
If you .gitmodules
file only has a url
and path
value set for a specific submodule, then the checked out hash of the submodule will be included in the comment if the "parent" repository.
You can verify this in the log dialog when you diff a commit which contains a submodule, then you can see the hash of the submodule there. Unless this commit is checkedd out in the submodule, it will be reported as modified in the parent repository.
In order to update the submodules to that specific version (e.g., after a pull or switch/checkout), you need to run "Submodule update" (possibly with the force option in order to force the submodule to that revision - this might cause data loss in the submodule locally).
Further reading:
Upvotes: 2