muffel
muffel

Reputation: 7360

Git: Checkout specific commit and get corresponding submodule version

I want to checkout a specific past commit of a git repository, let's say its hash is 'a1bc2def3':

git checkout a1bc2def3

The git repository makes heavy use of submodules. As their latest version is incompatible with the old commit, I want to checkout the latest commit of each submodule at the time of the local commit 'a1bc2def3'.

Do you know if there is a way to achieve that?

Upvotes: 4

Views: 1500

Answers (1)

Sigi
Sigi

Reputation: 1864

All you have to do is to run

git submodule update

after your checkout operation in the superproject.

Your subprojects (submodules) will then be checked out to the commit they were at when your superproject commit was created (they one that you have just check out with e.g. git checkout a1bc2def3).

Upvotes: 4

Related Questions