Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 361
muffel Avatar asked Oct 20 '25 14:10

muffel


1 Answers

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).

like image 159
Sigi Avatar answered Oct 23 '25 07:10

Sigi