Damo
Damo

Reputation: 384

git checkout version including submodules

How can I checkout a git repo including its submodules?

e.g. I have a repo A, with a submodule B, the commit history is as follows:

I want to temporarily go back to an older version of A, so I stashed local changes in A and B, then git checkout 0ec21a1

But Im still on the latest version of the submodule. I expected the submodule to updated according to the parent version. My understanding from this question, submodule tag is that git does not manage submodules when you checkout the parent, is this correct?

My real commit history is more complicated and there are several submodules. Is there a way to determine what version of submodule B was used in commit xxx of A? I can get approximate versions by comparing the git logs but it's rather painful...

Upvotes: 2

Views: 398

Answers (1)

nicole
nicole

Reputation: 101

git checkout 0ec21a1 --recurse-submodules will update the content of submodule B (if it's already initialized) according to the commit which is stored in parent project A (in this case will checkout e79fea0)

Upvotes: 3

Related Questions