Checkout past git submodule commit

$ git submodule update
Submodule path 'vendor/plugins/pluginA': checked out '49d5cba84dcffc061db69813162d103feef31ecb'
Submodule path 'vendor/plugins/pluginB': checked out '4f442f0448c1826252933d5af8fb33cd64d76f6e'

means you have done a git pull, fetching and merging files and submodules to your project.
The SHA1 of those submodules in the upstream project (the one you have been pulling of) have changed.

You can change them back (git checkout aref within projectA, then cd .. and git add -A; git commit -m "advance submodule to aref" ), and push (or not) those submodules ref back to upstream if you want.

If you need to know what exact SHA1 was your submodule at before the submodule update, simply do a git show previousProjectSHA1 (previousProjectSHA1 being the previous SHA1 before your main project update

You will see something like:

new file mode 160000
index 0000000..4c4c5a2

That (4c4c5a2) is the submodule SHA1 you need to restore them to their previous state.

See git submodule update SO question to know more about the nature of submodules.

Leave a Comment