I have a git project (repo1) including a single submodule (repo2).
What I would like to achieve is to tag my project using an older commit of my submodule (like HEAD – 3).
I tried with a checkout of the submodule to the commit I want, but checkout is wrong since, committing in my project won’t track the proper revision.
I tried resetting my submodule to the commit I want, commit the project, and then pulling the submodule and committing the project, which is also wrong because:
$ git submodule update
fatal: reference is not a tree: 2c3d1a5936aa9469ecc1442cd4b101e1bbd3aada
Unable to checkout '2c3d1a5936aa9469ecc1442cd4b101e1bbd3aada' in submodule path 'repo2'
What would be the best — as well as nicest — procedure ?
Git submodule head 'reference is not a tree' error gives a beginning of an answer, but it stills links the HEAD of repo2 and not a chosen commit…
Suppose now that the tag is done, how can I tell my repo1 to set repo2 in the proper state for a tag:
git checkout 0.0.1
According to git submodule update, a simple
git submodule update
should suffice. It doesn’t checkout my submodule to the specified commit. Why ? Is that a … bug ?
This question seems really hard, but it is not — way from that.
The full procedure, starting from a git repo (repo1) with a submodule (repo2).
Now, if I need to tag an old commit of my repo2, here’s what I’d do:
adding is important to update thegitlinkto repo2’s commit hashNow, why did the
submodule updatedidn’t work ? The fact is I kept on trying to checkout a commit associated to a tag of repo1This didn’t work only because (note to self) I forgot that:
So there was no real trick here, simply a little pitfall that may happen again for some of us, hopefully they’ll end up here.